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 std::string name; 16 auto p = cli() | opt(name, "name")["-n"]["--name"]("the name to use"); 17 18 name = ""; 19 p.parse( { "TestApp", "-n", "Vader" } ); 20 test(REQUIRE(name == "Vader")); 21 22 name = ""; 23 p.parse( { "TestApp", "--name", "Vader" } ); 24 test(REQUIRE(name == "Vader")); 25 26 name = ""; 27 p.parse( { "TestApp", "-n=Vader" } ); 28 test(REQUIRE(name == "Vader")); 29 30 name = ""; 31 p.parse( { "TestApp" } ); 32 test(REQUIRE(name == "")); 33 34 name = ""; 35 p.parse( { "TestApp", "-f" } ); 36 test(REQUIRE(name == "")); 37 38 return test; 39 } 40