Move the help generation priority higher so it triggers before config
file processing.
Fixes#1099
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This has been bounced around for a couple years now
#474 and a few others have expressed desire to work with non-standard
option names. We have been somewhat resistant to that but I think it can
be done now. This PR adds a modifier `allow_non_standard_option_names()`
It is purposely long, it is purposely off by default. But what it does
is allow option names with a single `-` to act like a short option name.
With this modifier enabled no single letter short option names are
allowed to start with the same letter as a non-standard names. For
example `-s` and `-single` would not be allowed.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
- Polish empty lines and disable description printing for apps and
subcommands with empty name, empty group and with no options and
subcommands.
- Add commentDefaults() method to trigger to comment default value
options in case default_also is true, so that the result set of an
option is not pollute with default option values.
- In case dafault_also is true mark required but not yet configured
options as "<REQUIRED>" and not yet configured default options as "" in
a commented line in the config file.
---------
Co-authored-by: Volker Christian <volker.christian@fh-hagenberg.at>
From #1067, there is a bit of ambiguity in the handling of config file
with vector input and multiple consecutive parameters. For example
```toml
option1=[3,4,5]
option1=[4,5,6]
```
Currently this is handled as if it were
```toml
option1=[3,4,5,4,5,6]
```
But this could be confusing in the case where the input was referring to
a vector of vectors.
This PR adds a separator in the sequence to separate the vector so they
are two vectors of 3 elements each.
Will need to verify if this change has other side effects. It is a
pretty unusual situation.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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>
Take the configurability of an option into account when determining
ambiguous names and conflicts.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Fix an issue with environmental variable parsing in option_groups, and
an issue with remaining in config files.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Correct an anomaly when using config file processing with a default. In
this case the count always shows 1 even if the default file were not
actually used. This caused some issues in some applications and was a
change from previous versions.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Update and test with some newer compilers and cmake versions
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This PR is to further support for TOML. To allow and generate quoted
names in config files including those separated by the parent separator.
like
```toml
"sub"."sub2".value=1
'sub'.'sub.sub'.value=2
```
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Add escaping to quoted strings, differentiate between literal and
regular strings.
The goal is to make string processing in config files as close as
possible to toml standards. This means handing escape sequences
including unicode, and differentiating between literal strings and
regular strings in files and when splitting the command line. Also
allowing variable names in the files to be quoted.
This PR gets partway there. Removes some hacks from the previous PR to
deal with unusual option names and replaces with the quoted names.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.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>
Add some additional tests to try to get test coverage back to 100%
refactor the positional parsing to reduce code duplication
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
use it for the default in `set_config` and simplify and add more
flexibility to the the config processing, and potentially in other
options as well.
The reverse policy returns a vector but in reversed order from normal.
This is what we want in the config processing
Inspired by #862, and updated with recent code changes.
---------
Co-authored-by: Volker Christian <me@vchrist.at>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Fixes#890
Add parsing of environmental variables when supplied for the config file
option.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* update the storage of remaining argument for config files, so that they work through the `remaining_for_passthrough` with values when parsed a second time.
* style: pre-commit.ci fixes
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* tweak the parsing of files for flags with disable_flag_override, basically allow true as a valid value to be interpreted as the default in that case
* style: pre-commit.ci fixes
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* add some more tests for coverage and fix some confusing error situations with config files.
* style: pre-commit.ci fixes
* fix warning
* ci: fix coverage
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
* add some coverage tests, and fix the issue with negated flags and config files
* style: pre-commit.ci fixes
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* fix the issue where subcommand callbacks would be triggered multiple times if specified as configurable.
* style: pre-commit.ci fixes
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* add a counting flag to address and issue with optional<bool> and make the flags more consistent
* move the add_flag to a single operation and add a Sum multi option policy
* style: pre-commit.ci fixes
* remove sum_flag_vector overloads
* style: pre-commit.ci fixes
* add limits include
* style: pre-commit.ci fixes
* fix some other warnings
* update docs describing the multi_option_policy
* Apply suggestions from code review
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
* add tests which suppose to pass
* Update ConfigFileTest.cpp
* Update ConfigFileTest.cpp
* style: pre-commit.ci fixes
* add the possibility for an empty vector result if allowed.
* style: pre-commit.ci fixes
* add empty vector command line tests
* update book and readme
* add no default test
Co-authored-by: puchneiner <90352207+puchneiner@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add a transform/validator that checks for files on a default path.
* update docs and add tests and capability of chaining the FileOnDefaultPath transform
* style: pre-commit.ci fixes
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
* add test of "or" operation and few doc additions
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
* add a few tests related to github issues
* change how the default is displayed in the help message prev was =XXXX, this was confusing in some cases particularly with flags or with multiple option names. Now is [default=XXXX] which makes it clearer what the value represents.
* Try to fix RTTI issue
* style: pre-commit.ci fixes
* Fix subcommand callbacks being called multiple times if in an option group
* style: pre-commit.ci fixes
* remove extra group call
* change [default=XXXXD] to just [XXXXX] for the default specification
* update changelog
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* add some capabilities to the config parser and a stream parser
* style: pre-commit.ci fixes
* add additional tests for the config parser
* additional tests of config sections and indexing
* style: pre-commit.ci fixes
* add initialization for member variables
* warning and error fixes
* add test for `parse_from_stream`
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add configuration output multi-line description tests
This adds tests for the application's description as well as option
groups and subcommands.
See #592.
* Fix commenting of configuration output multi-line descriptions
* add a get_single_name function for options, and allow short names to be used for configuration output.
* add config input to handle short and positional options
* add some tests about short options and positional options in config files
* allow use of envname_ in config files
* update doc book and readme with fixes
* formatting update
* some formatting updates
* add some notes on the config file generation
* just try modifying a comment
* 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
* work on the flags book chapter and making sure the values are initialized properly.
* Fix initialization of values used in flags or options
* update some formatting and more brace initialization
* update more formatting and fix a incorrect initializer
* more formatting and some error fixes
* more formatting
* Small formatting fix
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
Refactor some of the configuration file handling code. Make it easier to get the actual file that was processed, and allow extras in the config file to be ignored (default now), captured or errored.
fix std::error reference and formatting
add test for required but no default and fix a shadow warning on 'required' from gcc 4.8
Test correctness of config write-read loop
fix config generation for flag definitions
make the config output conform with toml
continue work on the config file interpretation and construction
get all the ini tests working again with the cleaned up features.
update formatting
rename IniTest to ConfigFileTest to better reflect actual tests and add a few more test of the configTOML
disambiguate enable/disable by default to an enumeration, and to make room for a configurable option to allow subcommands to be triggered by a config file.
add a ConfigBase class to generally reflect a broader class of configuration files formats of similar nature to INI files
add configurable to app and allow it to trigger subcommands
add test of ini formatting
add section support to the config files so sections can be opened and closed and the callbacks triggered as appropriate.
add handling of option groups to the config file output
add subcommand and option group configuration to config file output
subsubcom test on config files
fix a few sign comparison warnings and formatting
start working on the book edits for configuration and a few more tests
more test to check for subcommand close in config files
more tests for coverage
generalize section opening and closing
add more tests and some fixes for different configurations
yet more tests of different situations related to configuration files
test more paths for configuration file sections
remove some unused code and fix some codacy warnings
update readme with updates from configuration files
more book edits and README formatting
remove extra space
Apply suggestions from code review
Co-Authored-By: Henry Schreiner <HenrySchreinerIII@gmail.com>
fix some comments and documentation
fix spacing
Rename size_t -> std::size_t
Fix compiler warnings with -Wsign-conversion
Fix new warnings with -Wsign-conversion in PR