fix an issue where an enumeration with a stream output method would
generate strings that could not be converted back to the original
enumeration value.
Fixes Issue #1258
recent changes fixed a few issues with the default_val method. The
method used the to_string, which in cases where a user supplied a
streaming operation to enumerations they could not be converted back to
the enumeration properly resulting in some errors and confusing help
output.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
include impl headers with precompiled option.
This may be necessary for some package installs if they wish to include
the precompiled static library alongside the header only install.
inspired by #1198
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Update documentation related to formatters and some other recent
updates.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Add some controls to manipulate option string formatting, including
disabling the default values, disabling default flag values, disabling
type names.
Fixes#857
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Based on #1242, I don't think this is required but it does remove that
issue and checking on compiler explore it does simplify the generated
code.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Adds @LunarWatcher as a contributor for doc.
This was requested by phlptp [in this
comment](https://github.com/CLIUtils/CLI11/pull/1239#issuecomment-3434894391)
[skip ci]
---------
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Adds @TheodorNEngoy as a contributor for infra.
This was requested by phlptp [in this
comment](https://github.com/CLIUtils/CLI11/pull/1225#issuecomment-3418608931)
[skip ci]
---------
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Fix the help spacing and double printing of footers in certain
circumstances
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Extension allowing all possible priority combinations.
Add a field callback_priority to OptionBase.
---------
Co-authored-by: Philip Top <phlptp@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Adds @romanholidaypancakes as a contributor for code.
This was requested by phlptp [in this
comment](https://github.com/CLIUtils/CLI11/pull/1206#issuecomment-3292000117)
[skip ci]
---------
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Rework some of the validator locations, add documentation, and fix some
lingering issues with validators.
The extra will will enable additions of some new validators and reduce
compile times for those that are not needed.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
fix an issue with duplicate footers being printed with help_all
Fixes#1183
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
generating a seg fault if no default and no config file provided.
Fixes#1197
This was likely introduced by the combination of fixes for some issues
with the config parsing and some updates to the as<T> method a while
back. This edge case on the handling of the config pointer with as was
not overlooked in the earlier testing.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
The default formatter has hardcoded ratio at which the long options are
aligned. It's currently 1/3 of the column, which makes the default look
awkward:
```
-h, --help Print
--option Something
```
A ->long_option_alignment_ratio(6/30.f) allows output to look like this:
```
-h, --help Print
--option Something
```
The 1/3 ratio is also bad if you want to print "descriptive" long
options on a single line, because then you might want to increase the
column width, but that means you waste more space on short options.
e.g. ->column_width(46)
```
-l, --very-descriptive-long-option Something
```
vs. ->column_width(38)
```
-l, --very-descriptive-long-option
Something
```
vs. ->column_width(38) ->long_option_alignment_ratio(6/38.f)
```
-l, --very-descriptive-long-option Something
```
Any absolute offset `X` can be set as `X/column_width`, so provide a
ratio-based interface.
I would have prefered to give an absolute integer offset, but we still
have to preserve the functionality that does 1/3 if user changed
nothing, which means that ratio-based interface is simpler.
I don't have a good idea for the name, "short_option_ratio" might work
as well.
The setter does not sanity check that the value is in [0;1] range.
---------
Signed-off-by: Radim Krčmář <radim@krcmar.dev>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Address Issue #881, allowing use of string_view in the as<XX> method on
options.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
3.15 is a good minimum these days, and what pybind11, etc. now use.
(Edit: we are using some really old docker containers, so let's do 3.14+
for now).
---------
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Add two presets (default and tidy).
---------
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Check the requirements first.
Previously the callbacks were done first, but with custom callbacks this
cause side effects unexpectedly.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
try some things with no standard libraries
Add arm64 and freebsd build and tests
fix a discrepancy in the handling of chars on Arm processors
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
I am starting to use CLI11 in a project and I came across an
inconvenience in code like this
```c++
const std::string description(std::format("description"));
app.add_flag("--flag", description);
```
As far as I can tell. I cannot directly use the description here. The
reason seems to be to distinguish between assignment and description. So
only `const std::string` or `const char*` and so on can be used here.
But a `const std::string &&` can not be used.
With the changes in the PR the code can also be written like this:
```c++
app.add_flag("--flag", std::format("description"));
```
The `add_flag` function can then be used with a const string or an
rvalue reference to a string.
A bit OT: I was a bit confused by this part of the existing comment ` if
a variable string is passed that variable will be assigned the results
from the flag` I think this might be wrong, but I am not sure.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Azure windows 2019 image is being deprecated, shift CI to windows-2022
and windows 2025 images
add tests for coverage and a few missing checks for duplication options.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
add mechanic for fuzzing subcommands, and several fixes for found issues
from longer fuzzer runs
This includes some issues with option group positional name ambiguity, issue with join multioption policy and config files, and a few edge cases for configuration of multiline output interpretation.
Also added complex variables to the options, no issues found from this addition.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>