module Command_line: sig
.. end
Typed command-line parsing for your shell scripts, à la Prtinf.scanf
.
Use this module like OCaml's Printf.scanf
function.
Example:
Here is a potential argument specification for a shell script
that downloads and unarchives them (see also "src/test/examples.ml"
).
let cli_spec =
Command_line.Arg.(
string
~doc:"The URL to the stuff" ["-u"; "--url"]
~default:no_value
& flag ["-d"; "--remove-intermediary-files"]
~doc:"Remove intermediary files."
& string ["-f"; "--local-filename"]
~doc:"Override the downloaded file-name"
~default:no_value
& string ["-t"; "--tmp-dir"]
~doc:"Use <dir> as temp-dir"
~default:(Genspio.EDSL.string "/tmp/genspio-downloader-tmpdir")
& usage "Download archives and decrypt/unarchive them.\n./downloader -u URL [-c] [-f <file>] [-t <tmpdir>]"
) in
Command_line.parse cli_spec
(fun ~anon url all_in_tmp filename_ov tmp_dir ->
type 'a
cli_option = {
|
switches : string list ; |
|
doc : string ; |
|
default : 'a ; |
}
type '_
option_spec =
type ('_, '_)
cli_options =
module Arg: sig
.. end
val parse : ('a, unit EDSL.t) cli_options ->
(anon:string list EDSL.t -> 'a) -> unit EDSL.t