package devkit

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Devkit_core.ExtArgSource

include module type of struct include Arg end
Sourcetype spec = Arg.spec =
  1. | Unit of unit -> unit
    (*

    Call the function with unit argument

    *)
  2. | Bool of bool -> unit
    (*

    Call the function with a bool argument

    *)
  3. | Set of bool ref
    (*

    Set the reference to true

    *)
  4. | Clear of bool ref
    (*

    Set the reference to false

    *)
  5. | String of string -> unit
    (*

    Call the function with a string argument

    *)
  6. | Set_string of string ref
    (*

    Set the reference to the string argument

    *)
  7. | Int of int -> unit
    (*

    Call the function with an int argument

    *)
  8. | Set_int of int ref
    (*

    Set the reference to the int argument

    *)
  9. | Float of float -> unit
    (*

    Call the function with a float argument

    *)
  10. | Set_float of float ref
    (*

    Set the reference to the float argument

    *)
  11. | Tuple of spec list
    (*

    Take several arguments according to the spec list

    *)
  12. | Symbol of string list * string -> unit
    (*

    Take one of the symbols as argument and call the function with the symbol

    *)
  13. | Rest of string -> unit
    (*

    Stop interpreting keywords and call the function with each remaining argument

    *)
  14. | Rest_all of string list -> unit
    (*

    Stop interpreting keywords and call the function with all remaining arguments

    *)
  15. | Expand of string -> string array
    (*

    If the remaining arguments to process are of the form ["-foo"; "arg"] @ rest where "foo" is registered as Expand f, then the arguments f "arg" @ rest are processed. Only allowed in parse_and_expand_argv_dynamic.

    *)

The concrete type describing the behavior associated with a keyword.

Sourcetype key = string
Sourcetype doc = string
Sourcetype usage_msg = string
Sourcetype anon_fun = string -> unit
Sourceval parse_dynamic : (key * spec * doc) list ref -> anon_fun -> usage_msg -> unit

Same as Arg.parse, except that the speclist argument is a reference and may be updated during the parsing. A typical use for this feature is to parse command lines of the form:

  • command subcommand options where the list of options depends on the value of the subcommand argument.
  • since 4.01.0
Sourceval parse_argv : ?current:int ref -> string array -> (key * spec * doc) list -> anon_fun -> usage_msg -> unit

Arg.parse_argv ~current args speclist anon_fun usage_msg parses the array args as if it were the command line. It uses and updates the value of ~current (if given), or Arg.current. You must set it before calling parse_argv. The initial value of current is the index of the program name (argument 0) in the array. If an error occurs, Arg.parse_argv raises Arg.Bad with the error message as argument. If option -help or --help is given, Arg.parse_argv raises Arg.Help with the help message as argument.

Sourceval parse_argv_dynamic : ?current:int ref -> string array -> (key * spec * doc) list ref -> anon_fun -> string -> unit

Same as Arg.parse_argv, except that the speclist argument is a reference and may be updated during the parsing. See Arg.parse_dynamic.

  • since 4.01.0
Sourceval parse_and_expand_argv_dynamic : int ref -> string array ref -> (key * spec * doc) list ref -> anon_fun -> string -> unit

Same as Arg.parse_argv_dynamic, except that the argv argument is a reference and may be updated during the parsing of Expand arguments. See Arg.parse_argv_dynamic.

  • since 4.05.0
Sourceval parse_expand : (key * spec * doc) list -> anon_fun -> usage_msg -> unit

Same as Arg.parse, except that the Expand arguments are allowed and the current reference is not updated.

  • since 4.05.0
Sourceexception Help of string

Raised by Arg.parse_argv when the user asks for help.

Sourceexception Bad of string

Functions in spec or anon_fun can raise Arg.Bad with an error message to reject invalid arguments. Arg.Bad is also raised by Arg.parse_argv in case of an error.

Sourceval usage_string : (key * spec * doc) list -> usage_msg -> string

Returns the message that would have been printed by Arg.usage, if provided with the same parameters.

Sourceval current : int ref

Position (in Sys.argv) of the argument being processed. You can change this value, e.g. to force Arg.parse to skip some arguments. Arg.parse uses the initial value of Arg.current as the index of argument 0 (the program name) and starts parsing arguments at the next element.

Sourceval read_arg : string -> string array

Arg.read_arg file reads newline-terminated command line arguments from file file.

  • since 4.05.0
Sourceval read_arg0 : string -> string array

Identical to Arg.read_arg but assumes null character terminated command line arguments.

  • since 4.05.0
Sourceval write_arg : string -> string array -> unit

Arg.write_arg file args writes the arguments args newline-terminated into the file file. If the any of the arguments in args contains a newline, use Arg.write_arg0 instead.

  • since 4.05.0
Sourceval write_arg0 : string -> string array -> unit

Identical to Arg.write_arg but uses the null character for terminator instead of newline.

  • since 4.05.0
Sourceval describe : string -> string -> string -> string
Sourceval make_arg : < kind : string ; show : 'a -> string ; store : 'a -> 'b.. > -> string -> 'a -> string -> string * 'b * string
Sourceval test_int : (int -> bool) -> < kind : string ; show : int ref -> string ; store : int ref -> Arg.spec >
Sourceval string : < kind : string ; show : 'a ref -> 'a ; store : string ref -> Arg.spec >
Sourceval int_option : < kind : string ; show : int option ref -> string ; store : int option ref -> Arg.spec >
Sourceval float_option : < kind : string ; show : float option ref -> string ; store : float option ref -> Arg.spec >
Sourceval str_option : < kind : string ; show : string option ref -> string ; store : string option ref -> Arg.spec >
Sourceval int : string -> int ref -> string -> string * Arg.spec * string
Sourceval float : string -> float ref -> string -> string * Arg.spec * string
Sourceval str : string -> string ref -> string -> string * Arg.spec * string
Sourceval duration : string -> float ref -> string -> string * Arg.spec * string
Sourceval may_int : string -> int option ref -> string -> string * Arg.spec * string
Sourceval may_float : string -> float option ref -> string -> string * Arg.spec * string
Sourceval may_str : string -> string option ref -> string -> string * Arg.spec * string
Sourceval positive_int : string -> int ref -> string -> string * Arg.spec * string
Sourceval bool : string -> bool ref -> string -> string * Arg.spec * string
Sourceval usage_header : string
Sourceval align : ?sep:string -> (key * spec * doc) list -> (key * spec * doc) list
Sourceval parse : ?f:anon_fun -> (key * spec * doc) list -> unit
Sourceval usage : (key * spec * doc) list -> unit
Sourceval two_strings : (string -> string -> unit) -> Arg.spec
Sourceval rest : unit -> string list
OCaml

Innovation. Community. Security.