GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||
GeezerVison is showing cpp.libhunt.com โ jarro2783/cxxopts Alternatives - C++ CLI | LibHunt jarro2783/cxxoptsLightweight C++ command line option parser
Take the C++ Developer Survey
- About 6 minutes on the tools, libraries and AI you use with C++. You get the results by email.
Take the survey ยป
Popularity
7.9
Stable
Activity
6.6
Growing
Stars
4,830
Watchers
52
Forks
676
Last Commit
Programming language: C++
License: MIT License
Tags:
CLI
Latest version: v3.0
jarro2783/cxxopts alternatives and similar libraries
Based on the "CLI" category.
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
Promo
www.saashub.com
* Code Quality Rankings and insights are calculated and provided by Lumnify.
Do you think we are missing an alternative of jarro2783/cxxopts or a related project? READMERelease versionsNote that Version 3 breaking changesIf you have used version 2, there are a couple of breaking changes in version 3
that you should be aware of. If you are new to The parser no longer modifies its arguments, so you can pass a const The
Quick startThis is a lightweight C++ option parser library, supporting the standard GNU style syntax for options. Options can be given as:
where c takes an argument, but a and b do not. Additionally, anything after Basics
Create a
Then use
Options are declared with a long and an optional short option. A description must be provided. The third argument is the value, if omitted it is boolean. Any type can be given as long as it can be parsed, with operator>>. To parse the command line do:
To retrieve an option use
to get its value. If "opt" doesn't exist, or isn't of the right type, then an exception will be thrown. Note that the result of Unrecognised argumentsYou can allow unrecognised arguments to be skipped. This applies to both
positional arguments that are not parsed into another option, and
and in the result object they are retrieved with:
ExceptionsExceptional situations throw C++ exceptions. There are two types of
exceptions: errors defining the options, and errors when parsing a list of
arguments. All exceptions derive from All exceptions define a Help groupsOptions can be placed into groups for the purposes of displaying help messages.
To place options in a group, pass the group as a string to Positional ArgumentsPositional arguments are those given without a preceding flag and can be used alongside non-positional arguments. There may be multiple positional arguments, and the final positional argument may be a container type to hold a list of all remaining positionals. To set up positional arguments, first declare the options, then configure a set of those arguments as positional like:
Then parsing a set of arguments like:
will result in parsed arguments like the following table:
Default and implicit valuesAn option can be declared with a default or an implicit value, or both. A default value is the value that an option takes when it is not specified on the command line. The following specifies a default value for an option:
An implicit value is the value that an option takes when it is given on the command line without an argument. The following specifies an implicit value:
If an option had both, then not specifying it would give the value Note that the default and implicit value is always stored as a string, regardless of the type that you want to store it in. It will be parsed as though it was given on the command line. Default values are not counted by Boolean valuesBoolean options have a default implicit value of
| ||||||||
| You are visitor 01402792 โ GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800ร600. No cookies required. |