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

611 Commits

Author SHA1 Message Date
Philip Top
cbbf20ed93
Ci build update (#1151)
update ci build images, remove ubuntu 20.04 and update a few others, fix some newer clang-tidy warnings

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-04-19 09:14:59 -07:00
Philip Top
70f98cb218
fuzzer failure --sub1.- interpreting as a short option (#1148)
and getting into odd situations

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-04-15 18:44:49 -07:00
huangqinjin
bc621a95ca
Fix compilation on VS2017 (#1143)
The compiler complains about C2131: expression did not evaluate to a
constant.

https://godbolt.org/z/a198P3bdM

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-04-13 07:17:59 -07:00
Philip Top
2d79205521
Fix some minor fuzzing issues. (#1138)
One in the fuzz check handling of NaN's and a pathway to generate a
HorribleError.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-03-11 18:21:46 -07:00
Philip Top
f871b625ee
Float parsing negative (#1140)
Fixes #1139 
Fix a bug relating to parsing negative floating point values with no
zero before decimal point in a context where an option could be
possible.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-03-11 07:08:38 -07:00
Philip Top
f75fd22ba3
add tests and fixes for array options (#1136)
Fixes #1135. Adds enable check to certain to_string functions as some
std::array operations were ambiguous.

The addition of the capability to convert tuples to strings created an
ambiguity in the case std::array, which acts like a tuple and a
container. So it worked with the container conversion before, but could
also work with the new tuple conversion. And we didn't have any tests to
catch this.

This PR resolves the ambiguity, and adds some tests to check that array
is handled well.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-03-07 07:47:56 -08:00
Comix
7ff65c16f2
fix: promoting uint8_t/int8_t to make it casting result printable (#1132)
The underlying type of uint8_t/int8_t is unsigned char and signed char,
but IOStreams was specified to treat them just like char.

so promoting the casting value to get the expected value.

Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-03-05 20:07:50 -08:00
Guillem Blanco
b0f63a4442
Fix spelling in Error.hpp (#1129)
Co-authored-by: Philip Top <phlptp@gmail.com>
2025-03-03 05:39:43 -08:00
Philip Top
4160d259d9
update version and changelog for 2.5 release (#1121)
update readme, changelog, and version for 2.5 release

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
2025-02-27 04:25:31 -08:00
Philip Top
92adf2c8c2
Allow trailing spaces on strings for conversions (#1115)
Allow trailing spaces on strings for conversions to floating point and
integers.

There was a potential confusing error that could occur if strings with
trailing spaces were converted to integer or floating point values. This
PR allows trailing spaces in the strings that would otherwise be
convertible to the appropriate numerical type.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-01-27 19:14:18 -08:00
Julien Marrec
10ac3e59a4
update macros for codecvt and support C++26 support on clang19 (#1113)
* Modifies #1100 
* That PR comes from https://github.com/phlptp/CLI11 and unfortunately I
have no way of opening a PR to that repo, pointing to that branch...

The commit you care about is
9a2884ad6a
@phlptp

where I fix the build error on LLVM 19 with C++26 after rooting the
actual template issue (see
https://github.com/CLIUtils/CLI11/issues/1098#issuecomment-2572715578)

It comes down to C++26 adding a tuple interface to std::complex
https://en.cppreference.com/w/cpp/numeric/complex/tuple_size

---------

Co-authored-by: Philip Top <phlptp@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-01-11 05:42:24 -08:00
Philip Top
74c86d4889
update copyright dates to 2025 (#1112) 2025-01-03 08:35:31 -08:00
Philip Top
f41e59b7f6
fix a fuzzing issue from a string as a bracket (#1110)
fix fuzzing issue

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-01-03 07:47:09 -08:00
Philip Top
d2b331f02a
Fix Issue #1090, (#1108)
max, min on positional was not respected, specifically max positionals
only filled up to min, and skipped over optional options.

Fixes #1090

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-12-30 12:34:47 -08:00
Philip Top
ecdcf633a5
Help priority adjustment (#1106)
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>
2024-12-26 06:13:36 -08:00
Josh Soref
ef50bb35c3
Spelling (#1101)
This PR corrects misspellings identified by the [check-spelling
action](https://github.com/marketplace/actions/check-spelling) (which is
an evolution of the script I used ages ago when I first made a PR
here...).

The misspellings have been reported at
https://github.com/jsoref/CLI11/actions/runs/12194174338#summary-34017587518

The action reports that the changes in this PR would make it happy:
https://github.com/jsoref/CLI11/actions/runs/12194174680#summary-34017588281

---------

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-12-22 14:03:24 -08:00
Philip Top
063b2c911c
Fuzz fail (#1097)
fix failing fuzz case involving binary string with a '\x' in it.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-11-30 07:13:49 -08:00
Marc
3306c444f2
Switch order of Usage and Description to make it UNIX standard (#1093)
When I rewrote the Help formatter (see #866) I mixed up the order of the
Usage and Description strings. I flipped the order to make it UNIX style
again.
All tests pass.
2024-11-25 05:21:01 -08:00
Philip Top
3539bd185f
Issue 1086 (#1087)
Fixes issue #1086.

In the default_val enums of uint8_t would read in as a string as they
could be converted to a string. This worked ok for normal values, but
when a check was added for specific strings, it caused an error when the
default_val was added. This PR fixes the issue.

The builder for coverage was updated to CMake 3.31 (by github), this
triggered an error in the coverage tool script. This led to updating
that script, which led to uncovering some missing coverage, which led to
additional tests, which led to some issues around single element tuples
support from #1081, which led to a few other issues that came up in the
to_string operation and templates.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-18 05:40:37 -08:00
Philip Top
af270cee4a
pair/tuple defaults (#1081)
add capability to accept pair/tuple default values and a little cleaner
parsing in some cases

Fixes #711

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-11-09 07:57:45 -08:00
Philip Top
5a03ee5838
Allow non standard option names like -option (#1078)
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>
2024-10-23 05:14:29 -07:00
Philip Top
f865d2b296
Feature config file format (#1075)
- 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>
2024-10-09 08:59:42 -07:00
Philip Top
ca66827263
Subcommand fallthrough (#1073)
Add modifier for subcommands to restrict subcommands falling through to
parent.
This will resolve #1022

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-10-09 04:46:45 -07:00
Marc
65442ad846
A better Help formatter (V2) (#866)
_This is the new PR I've mentioned to work on in PR #858_

## A better Help Formatter
_See below for images of the new help page_

Finally, after a lot of planning, understanding CLI11's codebase,
testing and coding, the new default Help Formatter is done. There are a
lot of changes to make the help page more readable and closer to UNIX
standards, see Changelog below for details. One of the highlights is
automatic paragraph formatting with correct line wrapping for App and
options/flag descriptions as well as the footer.
A goal was to provide more flexibility and better readability for the
help page while providing full compatibility with Apps using CLI11 (no
breaking changes and no changes to Apps required). Also better support
for different terminal sizes. Users can now specify three new optional
attributes: `right_column_width_`, `description_paragraph_width_` and
`footer_paragraph_width_`. See code documentation for more details. The
different columns for options/flags now scale with the set
`column_width_` value: Single dash flags occupy 33% of the set
`column_width_`, double dash flags and options (like REQUIRED) 66%.
These new attributes allow for indirectly respecting terminal geometry,
footer paragraph formatting has also been added (#355). This PR also
implements the issues #353 and #856.
The new help page formatting can also be used as an input for man page
generation, since it's oriented on the man page style (#413).
[help2man](https://www.gnu.org/software/help2man/) can be used to
generate man pages from help output (see comment down below for
example).

I thoroughly tested this code with all possible combinations of flags,
options, positionals, subcommands, validators, ...
So far everything works great.
I hope this PR looks good and meets all requirements. I'm looking
forward to the implementation of this PR into CLI11. If you have any
questions or suggestions feel free to comment.

### Fixed/implemented issues by this PR
- #353 Better options formatting
- #856 Space between options
- #355 Footer formatting
- #413 Man page generation can be achieved using help2man with the new
help formatting
- https://github.com/CLIUtils/CLI11/issues/384#issuecomment-570066436
Better help formatting can be marked as complete

### What about the failing tests?
Of course the tests expect the old help text format. This is why 6 of
the tests are failing. Since it is a bit of work to migrate the tests to
the new help format, I first wanted to push out this PR and get
confirmation before I'll update all the tests.
So please let me know if this PR gets implemented, what changes should
be made and then I'll migrate the tests to the new help format, either
in this PR or I'll make a new one.

## Changelog:
#### There are _no breaking changes_. Every App using CLI11 will work
with this new formatter with no changes required.
- Added empty lines at beginning and end of help text
- Removed double new-line between option groups for consistency. Now all
sections have the same number of new-lines
- Switched usage and description order
- Only show "Usage"-string if no App name is present. This provides
better readability
- Made categories (Options, Positionals, ...) capital
- Changed `ConfigBase::to_config` to correctly process capital
"OPTIONS"-group (only affects descriptions of the config file, not a
breaking change)
- Added a paragraph formatter function `streamOutAsParagraph` to
StringTools.hpp
- Made "description" a paragraph block with correct, word respecting
line wrapping and indentation (using the new paragraph formatter
function)
- Made the footer a paragraph block with correct, word respecting line
wrapping and indentation
- Updated documentation for `column_width_` to make it more clear
- Added new member: `right_column_width_`, added getter and setter for
`right_column_width_`
- Added new member: `description_paragraph_width_`, added getter and
setter for `description_paragraph_width_`
- Added new member: `footer_paragraph_width_`, added getter and setter
for `footer_paragraph_width_ `
- Positionals description are now formatted as paragraph with correct,
word respecting line wrapping
- Options description are now formatted as paragraph with correct, word
respecting line wrapping
- Short and long options/flags/names are now correctly formatted to
always be at the right position (also for subcommand options/flags)
- Short and long options/flags/names column widths scale linearly with
the `column_width_` attribute to better adapt to different
`column_width_` sizes
- Merged PR #860

## What's planned for the future?
- I'm thinking of better formatting the options of flags (like REQUIRED,
TEXT, INT, ...) and make them also in a seperate column. This way they
would also always be at the same position. However I decided against it
for this PR, since I wanted them to be as close as possible to the
actual flag. With my implementation it is quite easy to add this change
in the future.
- Subcommands: I'm planning on better formatting the Subcommands. With
this PR only the short and long flags/options of subcommands are better
formatted (like it is with the main flags, see images down below).
- Maybe implement a different way to display expected data type options
(TEXT, INT, ...). For example: `--file-name=<TEXT>` for long flags only
and if `disable_flag_override_` is false.
- Maybe add something like this:
https://github.com/CLIUtils/CLI11/issues/554

---------

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-10-07 08:13:04 -07:00
pre-commit-ci[bot]
924e3e84fc
chore(deps): pre-commit.ci autoupdate (#1072)
<!--pre-commit.ci start-->
updates:
- [github.com/pre-commit/mirrors-clang-format: v18.1.8 →
v19.1.0](https://github.com/pre-commit/mirrors-clang-format/compare/v18.1.8...v19.1.0)
<!--pre-commit.ci end-->

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-10-03 07:53:24 -07:00
Philip Top
8c6a73d343
Vector input to config file (#1069)
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>
2024-09-26 06:02:29 -07:00
Philip Top
f7600953d4
add a round trip test to the fuzzer (#1060)
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>
2024-09-23 06:13:47 -07:00
Philip Top
b038a403ca
Issue cleanup (#1059)
Fix docstring related to #1052 
Fix config_to_string with defaults #1007

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-07-29 05:32:11 -07:00
Philip Top
7be1740521
Extra subcommand print (#1058)
Fixes issue #1045

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-07-27 08:05:56 -07:00
Philip Top
4ecbdd83e5
conflicting option names (#1049)
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>
2024-06-03 09:23:07 -07:00
Philip Top
08d840bfbe
Group merge (#1039)
This PR adds a mechanism to hide groups but have their options visible
as part of the parent.
This works for option group names starting with a '+'

for example 
```
 CLI::App app;

    bool flag = false;
    std::optional<bool> optional_flag = std::nullopt;

    app.add_option("--tester");
    auto *m1=app.add_option_group("+tester");

    m1->add_option("--flag", flag, "description");
    m1->add_option("--optional_flag", optional_flag, "description");

    CLI11_PARSE(app,argc, argv);
```
will produce help as 
```txt
Options:
  -h,--help                   Print this help message and exit
  --tester
  --flag BOOLEAN              description
  --optional_flag BOOLEAN     description
```

instead of 
```
Options:
  -h,--help                   Print this help message and exit
  --tester
[Option Group: tester]
  Options:
    --flag BOOLEAN              description
    --optional_flag BOOLEAN     description

```

Fixes issue #1034 and a few other past issues or questions

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-05-20 11:14:55 -07:00
Henry Schreiner
6c7b07a878
chore: prepare version 2.4.2 (#1037)
Prepare for release.

---------

Signed-off-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: Philip Top <phlptp@gmail.com>
2024-05-04 00:50:51 -04:00
captainurist
2e8697cea1
Can add lexical_cast overloads constrained with enable_if (#1021)
Also works for overloads constrained with concepts or requirements.

Previously this wasn't working, which is a problem if you want to hook
some external serialization framework into CLI11 without painstakingly
going through all the types that said external framework supports.

This PR is related to https://github.com/CLIUtils/CLI11/issues/908.
2024-05-02 08:02:59 -07:00
Ethan Sifferman
8bf340d10b
fix: improved clarity in RequiredError (#1029)
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
2024-04-07 00:17:35 -04: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
pre-commit-ci[bot]
dc93d7a50c
chore(deps): pre-commit.ci autoupdate (#1020)
<!--pre-commit.ci start-->
updates:
- [github.com/psf/black: 24.2.0 →
24.3.0](https://github.com/psf/black/compare/24.2.0...24.3.0)
- [github.com/pre-commit/mirrors-clang-format: v17.0.6 →
v18.1.1](https://github.com/pre-commit/mirrors-clang-format/compare/v17.0.6...v18.1.1)
<!--pre-commit.ci end-->

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-03-19 05:30:33 -07:00
Philip Top
6cd171ad3f
get_subcommand_no_throw (#1016)
get_subcommand when used for parsing config files, was throwing and
catching as part of control flow and expected operation, this resulting
in a performance hit in select cases. A get_subcommand_no_throw was
added to resolve this issue.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-03-12 09:45:17 -07:00
Sam Hocevar
ffd11bfc01
Fix internal header include paths. (#1011)
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, and makes it harder to make CLI11 part of a
larger codebase.

This is a regression of #475.
2024-03-11 08:35:13 -07:00
Philip Top
d98a387d48
Bug fixes in latest release (#1005)
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>
2024-02-09 19:23:12 -08:00
Henry Schreiner
f4d0731ceb
chore: prepare for 2.4.1 (#1001)
Quick release fixing the missing header.

---------

Signed-off-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: Philip Top <phlptp@gmail.com>
2024-02-07 19:13:27 -08:00
Philip Top
cf6092bd88
Config count anomaly (#1003)
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>
2024-02-07 15:31:01 -08:00
Henry Schreiner
30ead5da4d
fix: transiative include issue (#996)
Fix #993. I tried include-what-you-use, but it reports too much stuff to
be able to pick out what's missing very effectively.

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
2024-02-05 11:06:29 -05:00
Henry Schreiner
b8edd50acf
fix: drop one arg parse shortcut (#987) 2024-01-30 22:03:20 -05:00
Philip Top
35aa92d71a
update supported cmake versions and add some tests with newer compilers (#972)
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>
2024-01-08 05:40:26 -08:00
Philip Top
9dfeefe2ba
update copyright date to 2024 (#971)
update copyright dates
2024-01-06 08:08:31 -08:00
Philip Top
de1c6a1207
Escape transform and docs (#970)
Update some documentation and add a string escape transformer so escaped
strings can be handled on the command line as well as in the config
files.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-01-06 06:29:46 -08:00
Philip Top
91101604d5
Support all capabilities for toml integers and floating point numbers (#968)
This PR add support for all TOML integer types.
This includes 
```
{"+99", 99},
    { "99",99 },
    { "0xDEADBEEF",0xDEADBEEF },
    { "0xdeadbeef",0xDEADBEEF },
    { "0xdead_beef",0xDEADBEEF },
    { "0xdead'beef",0xDEADBEEF },
    { "0o01234567",001234567 },
    { "0o755",0755 },
    { "0755",0755 },
    { "995862_262",995862262 },
    { "995862262",995862262 },
    { "+995862275",+995862275 },
    { "995'862'275",995862275 },
    {"0b11010110",0xD6},
    {"0b1101'0110",0xD6},
    {"1_2_3_4_5",12345},
```

So support for separators (Toml and C++ standards), binary(new),
hex(worked previously), and octal(new)

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-01-02 06:56:46 -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