jon.recoil.org

Module Command.FlagSource

Command-line flag specifications.

Sourcetype 'a t

Required flags must be passed exactly once.

Optional flags may be passed at most once.

Sourceval optional_with_default : 'a -> 'a Command.Arg_type.t -> 'a Command.Flag.t

optional_with_default flags may be passed at most once, and default to a given value.

listed flags may be passed zero or more times.

Sourceval one_or_more_as_pair : 'a Command.Arg_type.t -> ('a * 'a Base.list) Command.Flag.t

one_or_more_as_pair flags must be passed one or more times.

Sourceval one_or_more_as_list : 'a Command.Arg_type.t -> 'a Base.list Command.Flag.t

Like one_or_more_as_pair, but returns the flag values as a list.

no_arg flags may be passed at most once. The boolean returned is true iff the flag is passed on the command line.

Sourceval no_arg_register : key:'a Univ_map.With_default.Key.t -> value:'a -> Base.bool Command.Flag.t

no_arg_register ~key ~value is like no_arg, but associates value with key in the autocomplete environment.

Sourceval no_arg_some : 'a -> 'a Base.option Command.Flag.t

no_arg_some value is like no_arg, but will return Some value if the flag is passed on the command line, and return None otherwise.

Sourceval no_arg_required : 'a -> 'a Command.Flag.t

no_arg_required value is like no_arg, but the argument is required. This is useful in combination with choose_one_non_optional.

Sourceval no_arg_abort : exit:(Base.unit -> Base.Nothing.t) -> Base.unit Command.Flag.t

no_arg_abort ~exit is like no_arg, but aborts command-line parsing by calling exit. This flag type is useful for "help"-style flags that just print something and exit.

escape flags may be passed at most once. They cause the command line parser to abort and pass through all remaining command line arguments as the value of the flag.

A standard choice of flag name to use with escape is "--".

Sourceval map_flag : 'a Command.Flag.t -> f:('a -> 'b) -> 'b Command.Flag.t

map_flag flag ~f transforms the parsed result of flag by applying f.