package mirage

  1. Overview
  2. Docs

Module Functoria.CliSource

Command-line handling.

Sourcetype 'a args = {
  1. context : 'a;
  2. config_file : Fpath.t;
  3. context_file : Fpath.t option;
  4. output : string option;
  5. dry_run : bool;
}

The type for global arguments.

Sourceval default_args : unit args
Sourceval peek_args : ?with_setup:bool -> mname:string -> string array -> unit args option

peek_args ?with_setup argv parses the global command-line arguments. If with_setup is set (by default it is), interprets -v and --color to set-up the terminal configuration as a side-effect. Returns None if global command-line arguments are invalid.

Sourceval peek_output : string array -> string option

peek_full_eval argv reads the --output option from argv; the return value is None if option is absent in argv.

Sourceval pp_args : 'a Fmt.t -> 'a args Fmt.t

pp_args is the pretty-printer for args.

Sub-commands

Sourcetype 'a configure_args = {
  1. args : 'a args;
  2. depext : bool;
  3. extra_repo : (string * string) list;
}

The type for arguments of the configure sub-command.

Sourcetype 'a build_args = 'a args

The type for arguments of the build sub-command.

Sourcetype 'a clean_args = 'a args

The type for arguments of the clean sub-command.

Sourcetype 'a help_args = 'a args

The type for arguments of the help sub-command.

Sourcetype query_kind = [
  1. | `Name
  2. | `Packages
  3. | `Opam
  4. | `Files
  5. | `Dune of [ `Config | `Build | `Project | `Workspace | `Dist ]
  6. | `Makefile
]
Sourceval pp_query_kind : query_kind Fmt.t

pp_query_kind is the pretty-printer for query kinds.

Sourcetype 'a query_args = {
  1. args : 'a args;
  2. kind : query_kind;
  3. depext : bool;
  4. extra_repo : (string * string) list;
}

The type for arguments of the query sub-command.

Sourcetype 'a describe_args = {
  1. args : 'a args;
  2. dotcmd : string;
  3. dot : bool;
  4. eval : bool option;
}

The type for arguments of the describe sub-command.

Sourceval peek_full_eval : string array -> bool option

peek_full_eval argv reads the --eval option from argv; the return value is None if option is absent in argv.

Sourcetype 'a action =
  1. | Configure of 'a configure_args
  2. | Query of 'a query_args
  3. | Describe of 'a describe_args
  4. | Clean of 'a clean_args
  5. | Help of 'a help_args

A value of type action is the result of parsing command-line arguments using parse_args.

Sourceval pp_action : 'a Fmt.t -> 'a action Fmt.t

pp_action is the pretty-printer for actions.

Sourceval args : 'a action -> 'a args

args a are a's global arguments.

Evalutation

Sourceval eval : ?with_setup:bool -> ?help_ppf:Format.formatter -> ?err_ppf:Format.formatter -> name:string -> version:string -> configure:'a Cmdliner.Term.t -> query:'a Cmdliner.Term.t -> describe:'a Cmdliner.Term.t -> clean:'a Cmdliner.Term.t -> help:'a Cmdliner.Term.t -> mname:string -> string array -> 'a action Cmdliner.Term.result

Parse the functoria command line. The arguments to ~configure, ~describe, etc., describe extra command-line arguments that should be accepted by the corresponding subcommands.

There are no side effects, save for the printing of usage messages and other help when either the 'help' subcommand or no subcommand is specified.

Sourcetype 'a result = [
  1. | `Ok of 'a action
  2. | `Error of 'a args option * [ `Exn | `Parse | `Term ]
  3. | `Version
]

Similar to Cmdliner.Term.result but help is folded into `Ok and errors also carry global command-line parameters.

Sourceval peek : ?with_setup:bool -> mname:string -> string array -> unit result

peek is the same as eval but without failing on unknown arguments.

OCaml

Innovation. Community. Security.