Codebase list coq / 27f0da1d-79b5-4ae7-a969-c2ac3c20ed99/main test-suite / ocaml_pwd.ml
27f0da1d-79b5-4ae7-a969-c2ac3c20ed99/main

Tree @27f0da1d-79b5-4ae7-a969-c2ac3c20ed99/main (Download .tar.gz)

ocaml_pwd.ml @27f0da1d-79b5-4ae7-a969-c2ac3c20ed99/mainraw · history · blame

open Arg

let quoted = ref false
let trailing_slash = ref false

let arguments = [
  "-quoted",Set quoted, "Quote path";
  "-trailing-slash",Set trailing_slash, "End the path with a /";
]
let subject = ref None
let set_subject x =
  if !subject <> None then
    failwith "only one path";
  subject := Some x

let _ =
  Arg.parse arguments set_subject "Usage:";
  let subject =
    match !subject with
    | None -> failwith "no path given";
    | Some x -> x in
  Sys.chdir subject;
  let dir = Sys.getcwd () in
  let dir = if !trailing_slash then dir ^ "/" else dir in
  let dir = if !quoted then Filename.quote dir else dir in
  Format.printf "%s%!" dir