Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Feb 24 18:15
    henryiii commented #562
  • Feb 24 17:50
    opelx closed #562
  • Feb 24 17:50
    opelx commented #562
  • Feb 24 17:45
    phlptp commented #562
  • Feb 24 17:41
    opelx commented #562
  • Feb 24 17:33
    phlptp commented #562
  • Feb 24 17:30
    phlptp commented #562
  • Feb 24 17:29
    opelx commented #562
  • Feb 24 17:21
    opelx commented #562
  • Feb 24 16:44
    phlptp commented #562
  • Feb 24 16:38
    henryiii commented #562
  • Feb 24 16:35
    opelx opened #562
  • Feb 22 14:44
    KOLANICH edited #561
  • Feb 22 14:44
    KOLANICH edited #561
  • Feb 22 14:43
    KOLANICH edited #561
  • Feb 22 14:40
    KOLANICH edited #561
  • Feb 22 12:40
    KOLANICH edited #561
  • Feb 22 12:33
    KOLANICH edited #561
  • Feb 22 12:32
    KOLANICH edited #561
  • Feb 22 12:28
    KOLANICH edited #561
nurelin
@nurelin
ok, it works, thank you
great project, btw
Henry Schreiner
@henryiii
I belive manually removing a help option with remove_option might expose a bug - the remove_option was not checking to make sure the help pointer option was removed.
Henry Schreiner
@henryiii
Nice, the type system comes to my rescue - the pointer returned was const, so you couldn’t delete it :)
And, thanks :)
nurelin
@nurelin
Hello again
I was wondering if there was a reason here to not do the same with get_help_all_ptr()
Henry Schreiner
@henryiii
It was possibly written before help_all was added.
nurelin
@nurelin
do you want a PR ?
Henry Schreiner
@henryiii
Probaby should check for both then return the names joined with " or “?
Sure, let me go ahead and merge #196
CI’s not done. I’ll have to merge it later or tomorrow. Well, they shouldn’t clash. Go ahead.
nurelin
@nurelin
ok, I have a patch at nurelin/CLI11@909bca5 but I don't know how you do testing in your project
neither if the code style suits you
Henry Schreiner
@henryiii
Code style is checked, you can make the PR then I can push to it. Though if you have Docker or Clang-format you can run ./scripts/check-format.sh (spelling?) yourself.
And I can add the test, if you want to it’s probably in tests/HelpTest.cpp
nurelin
@nurelin
check-style.sh applied, PR is at CLIUtils/CLI11#197
Philip Top
@phlptp
@henryiii I was tinkering with custom parsers for some specific types I wanted to load directly from the command line. Resulted in overloading the CLI::detail::lexical_cast function for specific types. I put some examples and some readME modifications in a branch This doesn't change the library at all and I am not sure if that was an intended option for custom types But being I had a bunch of the same type of variable to convert the overloaded function is proving to be kind of convenient vs the lambda functions. If you want I can make PR but up to you.
Henry Schreiner
@henryiii
@phlptp Yes, that would be helpful. That was not originally possible (hence the description of how to do it other ways) but was made possible around 1.3-1.5 or so. Docs and examples are always useful.
Philip Top
@phlptp
Ok, I will make a PR. I was also trying to figure out if there was a way to have an option that takes one or two parameters like the add_complex function but entered as a single term. Then you could make an argument that generates a complex number from one or two arguments.
Philip Top
@phlptp
@henryiii I am curious why you have the CLI11 and looks like a few other tutorial books on gitlab but the code on github? just wondering whether there was some advantage of having the tutorial book on gitlab.
Henry Schreiner
@henryiii
It’s easier to setup the CI on gitlab for webpages (though it’s a bit easier now). No fake branch, no API key, etc.
Philip Top
@phlptp
I noticed as I was working through the code that there is no non-const version of the get_help_all_ptr function, I was wondering if there was a reason for this, whereas for the config_ptr and help_ptr there is const and non-const versions
Henry Schreiner
@henryiii
Probably was never needed so went unnoticed
Philip Top
@phlptp
Is there a way to have multiple copies of the same subcommand trigger in the same command line argument set? I was trying something and I got an ExtraError when I called a subcommand twice. I wasn't entirely sure if something I was tinkering with screwed something up or that was the expected behavior?
Henry Schreiner
@henryiii
I don’t think so, I only added multiple subcommand support in the last version or so, and probably didn’t tackle the same subcommand multiple times. Normal result binding would not work very well with that, since the values would get replaced.
Anything that is not in the tests is not yet supported ;)
Philip Top
@phlptp
Looking that the code that is kind of what I figured, but I wanted to be sure. In that case is it ever possible to have parsed_ and the result of count() on a subcommand ever be greater than 1?
That is true with multiple copies of the same subcommand, it probably doesn't make much sense, though there is an interesting case with option groups where you could have multiple subcommands with the same name that would get triggered in sequence.
In context I wasn't doing anything with the results I was testing some of the paths down into option_groups with subcommands and back up into the parents, and that results was a little unexpected, though it probably makes sense.
Henry Schreiner
@henryiii
I think it was supposed to support it, ./app commmand 1 command 2 should work with callbacks, but might not ever have been implemented and tested. I wrote Listing a subcommand twice should increment the count twice, in theory in CLIUtils/CLI11#178. So I think the count will not go above 1 for now.
I think ./app command command should work, though
Philip Top
@phlptp
let me try that on the master and see if it works there
Henry Schreiner
@henryiii
Nope, doen’t work propely in 1.7: https://wandbox.org/permlink/xY5yPh9S7tRHWaaR
With different names, it works, but not reparsing the same command.
So currently count > 1 is not supported. It also settable directly on a subcommand, I would think, at least a toggle for allowing a single match or multiple matches.
It was changed from a bool to an int to support that eventually, but it was never added.
Ordered callbacks was the feature it was waiting on, I believe
Philip Top
@phlptp

Yeah I got the same thing

TEST_F(TApp, DuplicateSubcommands) {

    auto foo = app.add_subcommand("foo");

    args = {"foo", "foo"};
    run();
    EXPECT_TRUE(*foo);
    EXPECT_EQ(foo->count(), 2);
}

fails.

Henry Schreiner
@henryiii
I believe there’s a check currently for a subcommand being parsed, and it will not match if it was.
Philip Top
@phlptp
yeah I saw that too. Do you think it should work?
Henry Schreiner
@henryiii
I’m just tryign to think if it is ever important to have ./app command command parse as 1 subommand and a positional argument. It might be best as a toggle. Allow multiparse or something like that. Some (normal?) subcommands might not really be designed to reparse
We can make callbacks work, but the “simple” way:
// setup subcommands
CLI11_PARSE(…);

if(subcommand1)
   cout <<  subcommand_x;
Would only show the final value of subcommand_x (an option in the subcommand)
We could make sure it was correct inside callbacks, though.
Philip Top
@phlptp
The main use case I can think of would be if you were building a command programmatically in stages and were interacting with different parts of a subcommand at different times. That wouldn't be a normal use case though.
Henry Schreiner
@henryiii
There’s also a PDFTK style interface; I don’t know if it uses multiple identical subcommands, but I could see it happening
Something like ./imagetool draw 0 1 draw 1 2 draw 2 1 to make a triangle, for a related example
Philip Top
@phlptp
interesting, do callbacks on subcommand get executed prior to parsing the next subcommand, or does it keep chaining until everything finishes?
Henry Schreiner
@henryiii
Parsing is completely finished, but the subcommands could have their callbacks run in the parsed order (currently I believe they still run in definition order)