This is the next phase of the fuzzer. It runs a round trip and makes
sure that the config files generated by the app will load into the same
results, to test full round trip on the config files.
Issues fixed
- fix a bug in the string escape code caught by initial round trip tests
- resolve inconsistencies in handling of {} for empty vector indication
between config and cli parsing
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Hello. Thank you for this tool.
I found a few small typos in the RequiredError class.
This is an error message I received:
```
Requires at most 2 options be used and 3were given from [filename,--get-size,--get-size2]
```
This PR changes the error message to
```
Requires at most 2 options be used but 3 were given from [filename,--get-size,--get-size2]
```
Happy to make changes as needed!
## Source
```cpp
std::string filename;
bool get_size = false;
CLI::App app{"Program to read a file specified as command-line argument"};
app.add_option("filename", filename, "File to read")->required();
app.add_flag("--get-size", get_size, "Print the size of the file");
app.add_flag("--get-size2", get_size, "Print the size of the file2");
app.require_option(1, 2); // Enforce only one flag can be input
CLI11_PARSE(app, argc, argv);
```
## Further Idea
Also, another idea I had was to remove required options from this error
message. In this example, "filename" is required, so a better error
message would be
```
Requires at most 1 options be used but 2 were given from [--get-size,--get-size2]
```
I'm happy to look into this if you feel it would be valuable
Added include-what-you-use pragmas to:
* let IWYU point users to the main include file CLI/CLI.hpp
* tell IWYU that CLI/CLI.hpp is the main exporting header.
This should fix#816
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Philip Top <phlptp@gmail.com>
This adds a round trip test for config file generation to the fuzzer.
(the next step after this PR will be a fuzzer that verifies that the
round trip actually matches the results.
This change ended up requiring quite a few minor changes to fix the
ambiguities between the config file generation and config file reader.
1). There was a number of potential conflicts between positional names
and regular option names that could be triggered in config files, this
required a number of additional checks on the positional naming to
ensure no conflicts.
2). flag options with disable flag override can produce output results
that are not valid by themselves, resolving this required flag input to
be able to handle an array and output the original value set of results.
3). strings with non-printable characters could cause all sorts of chaos
in the config files. This was resolved by generating a binary string
conversion format and handling multiline comments and characters, and
handling escaped characters. Note; I think a better solution is to move
to fully supporting string formatting and escaping along with the binary
strings from TOML now that TOML 1.0 is finalized. That will not be this
PR though, maybe the next one.
4). Lot of ambiguities and edge cases in the string splitter, this was
reworked
5). handling of comments was not done well, especially comment characters in the
name of the option which is allowed.
6). non printable characters in the option naming. This would be weird
in practice but it also cause some big holes in the config file
generation, so the restricted character set for option naming was
expanded. (don't allow spaces or control characters).
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Update some doc strings and error output for clarity
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add missing Macros.hpp include to Error.hpp
To address:
```
In file included from /ITKWebAssemblyInterface/include/itkPipeline.h:21:
In file included from /ITKWebAssemblyInterface-build/_deps/cli11-src/include/CLI/App.hpp:25:
In file included from /ITKWebAssemblyInterface-build/_deps/cli11-src/include/CLI/ConfigFwd.hpp:17:
/ITKWebAssemblyInterface-build/_deps/cli11-src/include/CLI/Error.hpp:75:5: error: unknown type name 'CLI11_NODISCARD'
CLI11_NODISCARD int get_exit_code() const { return actual_exit_code; }
^
```
* style: pre-commit.ci fixes
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Fix internal header include paths.
The extra leading "CLI/" part of include directives prevents the inclusion
of CLI.hpp from a relative directory without an extra -I or /I compiler
directive.
* Fix single header generation script.
Files included with "" should be relative to the header file location first.
* Add a dedicated version option to CLI11 to facilitate use of version flags, similar to help flags
* add some test for the version flag
* update errors and formatting
* clear up gcc 4.8 warnings
* add a few more tests
* fix compiler error
* fix a few comments, and change default version flag to only use "--version"
* remove `version` calls and tests
* formatting and add `std::string version()` back in.
* Add whitespace/comments check
* Adapt spacing in clang-format
* Fix cpplint whitespace/comments issues
* Grammar
* Do not use clang-format for comment spacing
* Fix with clang-format pre-commit hook
* Make CI fail with readability-container-size-empty flag
* Make CI fail with cppcoreguidelines-owning-memory flag
* Add all google checks, exclude specific ones
* Apply clang-tidy fixes
* Make timer constructors explicit
* Add check for unscoped namespaces
* Replace unscoped namespace by using-declaration
* Replace unscoped namespace by using-declaration
* add expanded type_size specification
* add some more checks for type_size_max
* continued work on getting type sizes more flexible
* make some more tweaks to option to split up validate and reduce sections
* git rid of exceptions on the type_size functions exceptions, allow any number to be entered for the min and max and don't make a distinction between flags and other types.
* add expected count
* add the allow extra args flag in an option
* start working in allow_extra_args
* write some stuff in the book, and continue working on the failing test cases
* fix a few more of the helpers tests
* a few more test cases running
* all tests pass, fixing calls in ini files
* get vector<pair> working and all tests passing
* change callback to use reference to remove allocation and copy operation
* add support and test for vector<vector<X>>
* change Validators_ to validators_ for consistency
* fix linux warnings and errors by reording some templates and adding some typename keywords
* add support for std::vector<X> as the cross conversion type so optional<std::vector<X>> is supported using the full template of add_option.
* a few more test cases to take care of some coverage gaps
* add missing parenthesis
* add some more tests for coverage gaps
* add test for flag like option
* add transform test for `as<X>` function and make it pass through the defaults
* add a few more tests and have vector default string interpreted correctly.
* add test for defaulted integer, and route default string for defaulted value which would otherwise be empty
* some code cleanup and comments and few more test coverage gap tests
* add more tests and fix a few bugs on the type size and different code paths
* remove path in results by fixing the clear of options so they go back to parsing state.
* get coverage back to 100%
* clang_tidy, and codacy fixes
* reorder the lexical_conversion definitions
* update some formatting
* update whitespace on book chapter
fix incorrect parenthesis
update some clang-tidy fixes mainly else after return but a few conversions from into to bool
add extra newline before footer
add an extra field to the extra Error
add a footer callback for help operations
* change the move function to _move_option and add an additional test
add a validation check on min options to make sure it is even possible to succeed.
add some additional tests to cover code paths and potential errors.
add a number of additional tests and checks and fix some issues with the add function in option_groups
clean up example and help formatting
add option_groups example to play with
move create_option_group to a member function using a dummy template
add some optionGroup tests
add min and max options calls and an associated Error call
* add ranges example, add excludes to app for options and subcommands.
* add some tests on ranges, and some subcommand tests with exclusion
* add tests in optionGroups for some invalid inputs
* add required option to subcommands and option_groups
* add disabled flag
* add disable option to subcommands and some more tests
* start work on ReadMe modifications
* update the readme with descriptions of function and methods added for option_groups
* clear up gcc 4.7 warnings
* some update to the Readme and a few more warnings fixed
* Minor readme touchup
add some comments in readME about performance
move operator[] to return const Option *
Apply suggestions from code review
Co-Authored-By: phlptp <top1@llnl.gov>
update readme and add some IniTests and fix a bug from the tests
add_flag_callback
add a few tests to capture the different paths
fix incorrectly updated CMAKE file, and add some subcommand test for option finding
add disable_flag_override and work out some kinks in the find option functions
add some more tests and fix a few bugs in as<> function for options
Allow general flag types and default values, add shortcut notation for retrieving values
* Clear up Wshadow warnings from gcc 4.9. Most of these were local variable names with the same name as a member function.
Also a few spelling fixes and adding some std::move around some of the arguments when appropriate.
* Touchup
in progress: formatters
Getting closer
Working on apps
One test actually runs
All builds, added filter functions
Reverting a few behavours as needed
Repairs
All tests pass
Fixing error with adding help flag
Labels are simpler mappings, normalized setters
Adding help_all
Adding a few more tests
One more line tested
Adding one more check
Adding to readme
Simplify naming
Adding default constructors
Fixing spacing issues with subcommand all printout
Adding a couple of tests
* Adding nicer header with LICENSE to single file version
* Adding badges
* Clean up sh files
* Adding explicit in a few places
* More fixes from codacy