Module EDSL.Command_line (.ml)

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
       (*
          `cli_spec` has type:

           (string Genspio.EDSL.t ->
            bool Genspio.EDSL.t ->
            string Genspio.EDSL.t -> string Genspio.EDSL.t -> unit Genspio.EDSL.t,
            unit Genspio.EDSL.t)
           Genspio.EDSL.Command_line.cli_options
          
           so the action function (the second argument to parse) must have type:

           anon:string list Genspio.EDSL.t ->
           string Genspio.EDSL.t ->
           bool Genspio.EDSL.t ->
           string Genspio.EDSL.t ->
           string Genspio.EDSL.t ->
           unit Genspio.EDSL.t
       *)
       Command_line.parse cli_spec
         (fun ~anon url all_in_tmp filename_ov tmp_dir ->
            (*
               ...
               your code
               ...
            *)
     

type 'a cli_option = {
   switches : string list;
   doc : string;
   default : 'a;
}
type '_ option_spec = 
| Opt_flag : bool EDSL.t cli_option -> bool EDSL.t option_spec
| Opt_string : string EDSL.t cli_option -> string EDSL.t option_spec
type ('_, '_) cli_options = 
| Opt_end : string -> ('a, 'a) cli_options
| Opt_cons : 'c option_spec * ('a0, 'b) cli_options -> ('c -> 'a0, 'b) cli_options
module Arg: sig .. end
val parse : ('a, unit EDSL.t) cli_options ->
(anon:string list EDSL.t -> 'a) -> unit EDSL.t