Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply validators to defaults if no value was set from the comand line #305

Closed
Ozaq opened this issue Jul 27, 2019 · 1 comment
Closed

Apply validators to defaults if no value was set from the comand line #305

Ozaq opened this issue Jul 27, 2019 · 1 comment

Comments

@Ozaq
Copy link

Ozaq commented Jul 27, 2019

A rather common use case for me is to validate the existence of files passed to my program via commandline arguments. CLI11 features Opt::check(CLI::ExistingFile) but It seems to not get called if the option was not present on the command line but there is still a default, e.g.

std::filesystem::path file{"myfile"};
CLI::Option* opt1 = app.add_option("--inifile", file, "Path to your inifile");

I saw the workaround in #115 so consider this just as a though for improvement.

@phlptp
Copy link
Collaborator

phlptp commented Nov 10, 2019

So with #325 the value of the option specified as a default_str is run through the validators, which is wasn't previously. It still isn't going to check the value just stored in a variable that might get assigned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants