catchorg / Clara

A simple to use, composable, command line parser for C++ 11 and beyond
Boost Software License 1.0
648 stars 67 forks source link

Fix overloads of `Arg::parse()` #52

Open aghast opened 6 years ago

aghast commented 6 years ago

…to match Opt::parse(). Add test case parsing single Arg, no Opt.

I tried creating "simple" parser using Arg instead of Opt, based on the tutorial:

    int jumpto = 0;
    auto jarg = Arg(jumpto, "jump to");
    jarg.parse(Args{"exename", "10"});

This failed, because Arg is not using ParserBase::parse the way Opt does. So I added a test case, and the using statement required to resolve it.

/Users/austin/Code/clara/src/ClaraTests.cpp:83:43: error: too few arguments to function
      call, expected 2, have 1
        p.parse( Args{ "TestApp", "foo" } );
        ~~~~~~~                           ^
/Users/austin/Code/clara/include/clara.hpp:582:9: note: 'parse' declared here
        auto parse( std::string const &, TokenStream const &tokens ) const -> Int...
        ^
1 error generated.