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

Option value can't start with a dash #50

Open aivarsk opened 6 years ago

aivarsk commented 6 years ago

This test case fails:

TEST_CASE( "Opt value can start with a dash" ) {
    std::string name;
    bool showHelp = false;
    auto parser
            = Help( showHelp )
            | Opt( name, "name" )
                ["-n"]["--name"]
                ( "the name to use" );

    auto result = parser.parse( Args{ "TestApp", "-n", "-lfoobar" } );
    CHECK( result );
    REQUIRE( name == "-lfoobar" );
}

I have a program that receives compiler flags in arguments so a leading dash is common.

mike239x commented 5 years ago

Also related to this issue: if I have an option that takes an integer, it can no longer be negative, since Clara can't parse things that start this a minus.