Options C++ API#
Note
Generated from the C++ headers by apiary --emit-cpp-docs-json.
See the narrative documentation of this module for background and usage guidance.
Classes#
Builtins- The always-available –help and –version options.ConfigOption- An option declared completely, in one place.EnvTag- The environment variable name carried byEnv.ExclusiveCategory- A set of options of which at most one may be given.Flag- A boolean option whose meaning is carried by its presence.HelpEntry- One option’s contribution to –help, before layout.Location- Binds an option to storage that outlives parsing.NoEnvTag- Exempt this option from the registry’s automatic environment name derivation.OptEnum- An option whose value is one of a fixed set of named choices.OptionBase- The behaviour every option shares, whatever its value type.OptionCategory- A heading that groups related options in –help.Positional- Constructor tag marking an option positional rather than named.Range- Inclusive bounds applied to a numeric option after parsing.RegisteredOption- One registered option, flattened into data.Registry- Process-wide list of every declared option.Setter- A callback invoked every time an option receives a value.
Concepts#
Parsable- Types usable as the value type of Opt<T>, List<T>, and friends.SetterCallable- Anything acceptable as a Setter<T> callback.
Functions#
config_flag- Declare a boolean option. Registration also generates the –no- spelling, so a default-true flag needs no hand-written negation.config_opt- Declare a value option.config_opt_computed- Declare a value option whose default is only knowable at run time, such as the system temporary directory or a name built from the process id.derive_env_name- Derive an environment variable name from a prefix and an option name.derive_key- The config key derived from a command-line long name.derive_negated_name- The –no- spelling generated for a flag.Env- Read this option from a named environment variable.format_help- Render the full –help text.freeze_registry- Close the registry to new options.on_change- Hear about every change to an option’s value.parse- Parse command-line arguments into the previously registered options.parse_with_config- Parse command-line arguments, consulting a config file first.RangeBetween- Bounds for an integral option, e.g. RangeBetween(1, 256).read_config- Read a key = value or flat-JSON config file into a map.register_option- Give a descriptor its command-line, environment, and config presence.registered_option_values- Every option’s key and current value, rendered for a log or a dump.registered_options- Every option a descriptor has registered, in registration order.terminal_width- The width to wrap help text at, honouring COLUMNS and the terminal size.to_string- Human-readable name for a value source, for diagnostics and help text.unfreeze_registry_for_tests- Reopen the registry. For tests that declare options of their own; @ref Registry::clear_for_tests calls it.verify_registered_options- Assert that nothing registered so far contradicts anything else.get- The value in effect for an option.get_dynamic- Read an option by key, for keys built at run time.set- Write an option through its descriptor.set_dynamic- Write an option by key.try_get- The value, but only when something explicitly supplied it.
Enumerations#
Occurrence- How many times an option may, or must, be given.OptionKind- How an option is spelled on the command line.OptionType- The value type an option holds. A descriptor fixes it at declaration; the enumeration API hands it to callers who only see an option as data.Source- Where an option’s current value came from.ValueExpected- Whether an option takes a value, and whether it may go without one.Visibility- Whether an option appears in –help at all.