$ ./test
OK
$ ./test sub
OK
$ ./test bad
ERROR: Unrecognized token: bad
With 1.6.1 (and the latest develop) however:
$ ./test
OK
$ ./test sub
OK
$ ./test bad
ERROR: Expected: sub
This is quite confusing to users since sub isn't a "required sub-command".
The regression got introduced in 36e22c6a8ff539bdcafbcf2081c377a3f8b6ed98 but that's a fairly big commit and I haven't been able yet to track down the exact spot.
I've also written up a small unit test in case that's helpful:
// unrecognized_command_run_test.cpp
#include <lyra/lyra.hpp>
#include "mini_test.hpp"
bool error_contains(const lyra::parse_result& result, const std::string& expectedError)
{
const std::string& error =
#if LYRA_VERSION_MINOR == 5
result.errorMessage()
#else
result.message()
#endif
;
return error.find(expectedError) != std::string::npos;
}
int main()
{
using namespace lyra;
bfg::mini_test::scope test;
auto cli = lyra::cli()
.add_argument(lyra::command("sub"));
{
const auto result = cli.parse( { "TestApp" } );
test
(REQUIRE( result ))
;
}
{
const auto result = cli.parse( { "TestApp", "sub" } );
test
(REQUIRE( result ))
;
}
{
const auto result = cli.parse( { "TestApp", "bad" } );
test
(REQUIRE( !result ))
(REQUIRE( error_contains(result, "Unrecognized token") ))
;
}
return test;
}
There appears to be a regression in Lyra 1.6 vs. 1.5.1. Take the following parser with a single sub-command named
sub
:With 1.5.1 we get:
With 1.6.1 (and the latest
develop
) however:This is quite confusing to users since
sub
isn't a "required sub-command".The regression got introduced in 36e22c6a8ff539bdcafbcf2081c377a3f8b6ed98 but that's a fairly big commit and I haven't been able yet to track down the exact spot.
I've also written up a small unit test in case that's helpful: