1 /* 2 Copyright 2019-2022 René Ferdinand Rivera Morell 3 Distributed under the Boost Software License, Version 1.0. 4 (See accompanying file LICENSE.txt or copy at 5 http://www.boost.org/LICENSE_1_0.txt) 6 */ 7 8 #include <lyra/lyra.hpp> 9 #include "mini_test.hpp" 10 #include <string> 11 main()12int main() 13 { 14 using namespace lyra; 15 bfg::mini_test::scope test; 16 17 { 18 bool a = false; 19 auto cli = lyra::cli() | opt( a )["-a"]; 20 auto result = cli.parse( { "TestApp", "-b" } ); 21 test 22 (REQUIRE( !result )) 23 (REQUIRE( result.message().find( "Unrecognized token") != std::string::npos )) 24 (REQUIRE( result.message().find( "-b" ) != std::string::npos )); 25 } 26 #if 0 // Test case for https://github.com/bfgroup/Lyra/issues/24 27 { 28 bool o = false; 29 std::string a; 30 auto cli = lyra::cli() 31 .add_argument(opt( o )["--option"].optional()) 32 .add_argument(arg(a, "argument")); 33 auto result = cli.parse( { "TestApp", "--function", "arg" } ); 34 test 35 (REQUIRE( !result )) 36 (REQUIRE( result.message().find( "Unrecognized token") != std::string::npos )) 37 (REQUIRE( result.message().find( "--function" ) != std::string::npos )); 38 } 39 #endif 40 41 return test; 42 } 43