1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-04-29 12:13:52 +00:00

32 Commits

Author SHA1 Message Date
Philip Top
74c86d4889
update copyright dates to 2025 (#1112) 2025-01-03 08:35:31 -08:00
gostefan
2fa609ad55
Add IWYU pragmas (#1008)
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>
2024-03-19 17:49:34 -07:00
Philip Top
9dfeefe2ba
update copyright date to 2024 (#971)
update copyright dates
2024-01-06 08:08:31 -08:00
Philip Top
dc137f0c16
add support for quotes in the config naming to match TOML standard (#967)
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>
2023-12-31 05:52:30 -08:00
Philip Top
91220babfc
regular and literal strings (#964)
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>
2023-12-30 06:54:41 -08:00
Philip Top
0f5bf21e91
add some reduction methods to the options on the fuzz tests (#930)
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>
2023-12-18 05:21:32 -08:00
Henry Schreiner
48dce18d3a
fix: single header includes (#828)
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
2023-01-05 17:46:58 -05:00
Philip Top
39a5f1981e
chore: update copyright year to 2023 (#825) 2023-01-03 17:29:37 -05:00
Daniel Herrera Castro
003e82579e [precompile] Split Config.hpp 2022-08-23 11:42:02 -04:00
Henry Schreiner
c781998273
chore: clang tidy updates (#742)
* chore: update clang-tidy

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* refactor: address clang-tidy

* fix: C++11 support

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* chore: two more clang-tidy fixes

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* fix: get_inject_separator should be bool

* refactor: addressing review feedback

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Co-authored-by: Philip Top <phlptp@gmail.com>

* Apply suggestions from code review

* Update include/CLI/Config.hpp

* Update include/CLI/Config.hpp

* Update include/CLI/Config.hpp

* Update include/CLI/Config.hpp

Co-authored-by: Philip Top <phlptp@gmail.com>
2022-06-26 14:53:01 -04:00
Philip Top
4cae08686d
docs: update copyright dates to 2022 (#717) 2022-03-26 21:54:49 -04:00
Philip Top
8b785a6c7d
feat: add some capabilities to the config parser and a stream parser (#630)
* 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>
2021-08-22 23:53:06 -04:00
Henry Schreiner
b4f6be31c1
chore: codacity (#621)
* docs: fix some Codacity recommendations

* chore: update copyright year

* style: more codacity fixes

* style: fix issues reported by Codacity
2021-07-16 17:41:46 -04:00
Olaf Meeuwissen
2255619b0f
fix: commenting of descriptions with embedded newlines (#592)
* 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
2021-06-28 13:07:03 -04:00
Philip Top
a8ef5b8d2f
fix: avoid printing description for non configurable subcommand (#604) 2021-06-17 17:42:53 -04:00
Philip Top
ee2b725019
fix: a few issues with config file output (#599)
* fix a few issues with config file output, namely an ability to print a default empty string, and to adjust the quote characters used when quoting strings or characters.

* fix formatting

* Update CMakeLists.txt

* Update README.md
2021-06-16 21:58:03 -04:00
Henry Schreiner
f862849488
refactor: new version of MakeSingleFiles (#546)
* refactor: new version of MakeSingleFiles

* fix: use CMake and set version
2021-01-04 17:47:06 -05:00
D. Fleury
a7902531c9
fix: add multilines array support for TOML (#528)
* Adds multilines array support

* Update include/CLI/Config.hpp

Co-authored-by: David Fleury <david.fleury@expandium.com>
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
2020-10-28 12:34:24 -04:00
Sam Hocevar
2337bbf35d
Fix internal header include paths. (#475)
* 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.
2020-06-14 11:32:29 -04:00
Philip Top
f346f29802
Config short (#443)
* 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
2020-03-22 13:58:46 -04:00
Philip Top
967bfe0e02
Set the default configuration file output as TOML (#435)
* Set the default configuration file output as TOML

* update formatting
2020-03-06 00:11:59 -05:00
Christoph Bachhuber
d8a5bdc294
Add and fix cpplint whitespace/comments (#434)
* 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
2020-03-06 00:04:59 -05:00
Christoph Bachhuber
34bfa38691
Add copyright and copyright check (#424)
* Add copyright check

* Remove old license message

* Implement suggestions from code review
2020-02-10 14:28:47 -05:00
Christoph Bachhuber
88b0bc4d95 Add include_what_you_use to cpplint checks (#414)
* Add build/include_what_you_use to cpplint checks

* Fix all cpplint build/include_what_you_use issues
2020-01-26 14:01:54 -06:00
Christoph Bachhuber
efbdd604af Refactor clang-tidy (#389)
* 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
2020-01-08 17:32:30 -05:00
Henry Schreiner
4bfcc0e9c7 Fix error with clang tidy 2020-01-06 14:16:36 -05:00
Philip Top
c67ab9dd43 Config file handling refactor. (#362)
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
2019-12-31 11:28:25 -05:00
Philip Top
418b7175f5 Type size refactor (#325)
* 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
2019-11-10 05:36:16 +10:30
Henry Schreiner
d81843002a
To string and default option revamp (#242)
* First streaming version

* Using to_string instead

* Switching to new backend

* Moving to capture function for defaults

* Rename capture_default + _str

* defaultval -> default_str, added always_capture_default

* Fix style

* Adding tests and docs to readme

* Dropping macOS on Travis (supported through Azure)
2019-04-28 22:44:30 +02:00
ncihnegn
9cfa0f44a0 Add quotes to values containing spaces (#198)
* Add test case for INI output of defaulted options

* Add quotes to values with spaces

* Fixing formatting

* Only fix quote strings, not vectors
2019-01-19 12:25:00 +01:00
Henry Schreiner
76f1b7bdf2
Rename inijoin to ini_join (#137) 2018-06-23 21:48:20 +02:00
Henry Fredrick Schreiner
d46c2c5727 Adding Config class 2018-05-09 16:08:32 +02:00