Source file command_line.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
open! Import
module Raw = struct
type t =
{ program : string
; args : string list
}
let from_env () =
match Sys.argv |> Array.to_list with
| program :: args -> { program; args }
| [] -> failwith "unable to read command-line arguments from environment"
;;
end
module Rich = struct
type t =
{ program : string
; subcommand : string list
; args : string list
}
let to_raw { program; subcommand; args } = { Raw.program; args = subcommand @ args }
end