CLI11 is a command line parser for C++11 and beyond that provides a rich feature set with a simple and intuitive interface.
This version focuses on cleaning up deprecated functionality, and some minor default changes. The config processing is TOML compliant now. Atomics and complex numbers are directly supported, along with other container improvements. A new version flag option has finally been added. Subcommands are significantly improved with new features and bugfixes for corner cases. This release contains a lot of backend cleanup, including a complete overhaul of the testing system and single file generation system.
%%
separator #423
CLI::TypeValidator<TYPE>
#526
->silent()
on subcommands. #529
->capture_default_str()
instead. Use app.option_defaults()->always_capture_default()
to set this for
all future options. #597
add_option
on a complex number instead of add_complex
, which has been removed.This is a patch version that backports fixes from the development of 2.0.
Config file handling was revamped to fix common issues, and now supports reading TOML.
Adding options is significantly more powerful with support for things like
std::tuple
and std::array
, including with transforms. Several new
configuration options were added to facilitate a wider variety of apps. GCC
4.7 is no longer supported.
add_option
, allowing std::optional
to be supported without a special import #285
string_view
now supported in reasonable places #300, #285
immediate_callback
, final_callback
, and parse_complete_callback
added to support controlling the App callback order #292, #313
positionals_at_end
is set. #306
add_complex
#325, [#370][]CLI::NonNegativeNumber
and CLI::PositiveNumber
#342
CLI::deprecate_option
and CLI::retire_option
functions #358
default_val
[#387][]CL11_CLANG_TIDY
#390
checked_multiply
#290
->check()
was adding the name to the wrong validator #320
Converting from CLI11 1.8:
- Some deprecated methods dropped
add_set*
should be replaced with->check
/->transform
andCLI::IsMember
since 1.8get_defaultval
was replaced byget_default_str
in 1.8- The true/false 4th argument to
add_option
is expected to be removed in 2.0, use->capture_default_str()
since 1.8
Set handling has been completely replaced by a new backend that works as a Validator or Transformer. This provides a single interface instead of the 16 different functions in App. It also allows ordered collections to be used, custom functions for filtering, and better help and error messages. You can also use a collection of pairs (like std::map
) to transform the match into an output. Also new are inverted flags, which can cancel or reduce the count of flags, and can also support general flag types. A new add_option_fn
lets you more easily program CLI11 options with the types you choose. Vector options now support a custom separator. Apps can now be composed with unnamed subcommand support. The final bool "defaults" flag when creating options has been replaced by ->capture_default_str()
(ending an old limitation in construction made this possible); the old method is still available but may be removed in future versions.
.add_option("name", value, "", True)
becomes .add_option("name", value)->capture_default_str()
#242
.always_capture_default()
#242
CLI::IsMember
validator replaces set validation #222
CLI::AsNumberWithUnit
and CLI::AsSizeValue
#253
add_option
now supports bool due to unified bool handling #211
.remaining_for_passthrough()
#265
->delimiter(char)
#209, #221, #240
app.positionals_at_end()
#223
validate_positionals
#262
!
#230, and now handle tname functions #228
BUILD_TESTING
only if CLI11 is the main project; otherwise, CLI11_TESTING
must be used #277
Converting from CLI11 1.7:
.add_option(..., true)
should be replaced by.add_option(...)->capture_default_str()
orapp.option_defaults()->always_capture_default()
can be usedapp.add_set("--name", value, {"choice1", "choice2"})
should becomeapp.add_option("--name", value)->check(CLI::IsMember({"choice1", "choice2"}))
- The
_ignore_case
version of this can be replaced by addingCLI::ignore_case
to the argument list inIsMember
- The
_ignore_underscore
version of this can be replaced by addingCLI::ignore_underscore
to the argument list inIsMember
- The
_ignore_case_underscore
version of this can be replaced by adding both functions listed above to the argument list inIsMember
- If you want an exact match to the original choice after one of the modifier functions matches, use
->transform
instead of->check
- The
_mutable
versions of this can be replaced by passing a pointer or shared pointer intoIsMember
- An error with sets now produces a
ValidationError
instead of aConversionError
The parsing procedure now maps much more sensibly to complex, nested subcommand structures. Each phase of the parsing happens on all subcommands before moving on with the next phase of the parse. This allows several features, like required environment variables, to work properly even through subcommand boundaries.
Passing the same subcommand multiple times is better supported. Several new features were added as well, including Windows style option support, parsing strings directly, and ignoring underscores in names. Adding a set that you plan to change later must now be done with add_mutable_set
.
->allow_windows_style_options
. #187 On by default on Windows. #190
parse(string)
to split up and parse a command-line style string directly. #186
ignore_underscore
and related functions, to ignore underscores when matching names. #185
->description
to set Option descriptions #199
add_mutable_set*
, since the set reference should not expire #200
count()
with no arguments will return the number of times a subcommand was encountered. #179
shortcurcuits
, ini
, env
, callbacks
, and requirements
; all subcommands complete a phase before moving on. #179
clear
(automatic). #179
short_circuit
property, as help flag parsing is a bit more complex, and the default callback behavior of options now works properly. #179
BUILD_TESTING
over CLI11_TESTING
if defined (CLI11_TESTING
may eventually be removed) #183
set_footer
, set_name
, set_callback
, and set_type_name
. Use without the set_
instead. #192
Converting from CLI11 1.6:
->short_circuit()
is no longer needed, just remove it if you were using it - raising an exception will happen in the proper place now without it.->add_set*
becomes->add_mutable_set*
if you were using the editable set featurefooter
,name
,callback
, andtype_name
must be used instead of theset_*
versions (deprecated previously).
This version fixes some formatting bugs with help-all. It also adds fixes for several warnings, including an experimental optional error on Clang 7. Several smaller fixes.
detail::find_and_replace
added to utilitiesCLI11_INSTALL
flag. #156
--help
on subcommands (general fix planned for 1.7) #168
This version provides a few fixes for special cases, such as mixing with Windows.h
and better defaults for systems like Hunter. The one new feature is the ability to produce "branded" single file output for providing custom namespaces or custom macro names.
Added a new formatting system #109. You can now set the formatter on Apps. This has also simplified the internals of Apps and Options a bit by separating most formatting code.
CLI::Formatter
and formatter
slot for apps, inherited.FormatterBase
is the minimum required.FormatterLambda
provides for the easy addition of an arbitrary function.help_all
support (not added by default).Changes to the help system (most normal users will not notice this):
single_name
to get_name(false, false)
(the default).get_name()
is now get_name(false, true)
.get_pname()
is now get_name(true, false)
.help_*
functions._has_help_positional
removed.format_help
can now be chained.short_circuit
property to simplify parsing. #121
New for Config file reading and writing #121:
config_formatter()
and get_config_formatter()
.config_to_str
.ConfigItem
.Validators are now much more powerful #118, all built in validators upgraded to the new form:
CLI::Validator
is now also accepted.PATH
and INT in [1-4]
.&
and |
.Other changes:
parse(args)
's args
setting and ordering after parse. #141
set_custom_option
with type_name
and type_size
instead of set_custom_option
. Methods return this
. [#136]set_
on Option's type_name
, default_str
, and default_val
. [#136]set_
from App's failure_message
, footer
, callback
, and name
. [#136]N<-1
for type_size
. #140
->each()
to make adding custom callbacks easier. #126
add_option("-n",{})
to be edited later with each
#142
get_subcommands
, get_options
; use empty filter {}
to avoid filtering.get_groups()
to get groups.get_option
, set_results
, and empty
. #119
lname
and sname
have getters, added const get_parent
. #120
add_set
will now capture L-values for sets, allowing further modification. #113
get_type_name
(get_typeval
).requires
in favor of needs
(deprecated in last version). #112
Backend and testing changes:
This version fixes the optional search in the single file version; some macros were not yet defined when it did the search. You can define the CLI11_*_OPTIONAL
macros to 0 if needed to eliminate the search.