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 main()11int main() 12 { 13 using namespace lyra; 14 bfg::mini_test::scope test; 15 16 #if defined(LYRA_CONFIG_OPTIONAL_TYPE) 17 LYRA_CONFIG_OPTIONAL_TYPE<std::string> name; 18 auto p = cli() 19 | opt(name, "name") 20 ["-n"]["--name"] 21 ("the name to use"); 22 { 23 auto result = p.parse({ "TestApp" }); 24 test 25 (REQUIRE( result )) 26 (REQUIRE( !name.has_value() )); 27 } 28 { 29 auto result = p.parse({ "TestApp", "-n", "Pixie" }); 30 test 31 (REQUIRE( result )) 32 (REQUIRE( name.has_value() )) 33 (REQUIRE( name.value() == "Pixie" )); 34 } 35 #endif 36 37 return test; 38 } 39