| 1 | open Arg |
| 2 | |
| 3 | let quoted = ref false |
| 4 | let trailing_slash = ref false |
| 5 | |
| 6 | let arguments = [ |
| 7 | "-quoted",Set quoted, "Quote path"; |
| 8 | "-trailing-slash",Set trailing_slash, "End the path with a /"; |
| 9 | ] |
| 10 | let subject = ref None |
| 11 | let set_subject x = |
| 12 | if !subject <> None then |
| 13 | failwith "only one path"; |
| 14 | subject := Some x |
| 15 | |
| 16 | let () = |
| 17 | Arg.parse arguments set_subject "Usage:"; |
| 18 | let subject = |
| 19 | match !subject with |
| 20 | | None -> failwith "no path given"; |
| 21 | | Some x -> x in |
| 22 | Sys.chdir subject; |
| 23 | let dir = Sys.getcwd () in |
| 24 | let dir = if !trailing_slash then dir ^ "/" else dir in |
| 25 | let dir = if !quoted then Filename.quote dir else dir in |
| 26 | Format.printf "%s%!" dir |