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()11 int main()
12 {
13 	using namespace lyra;
14 	bfg::mini_test::scope test;
15 
16 	std::string value;
17 	auto cli = lyra::cli() | arg( value, "value" );
18 
19 	value = "";
20 	{
21 		char* exec_args[] = { (char*)"TestApp", (char*)"hello" };
22 		auto result = cli.parse( { 2, exec_args } );
23 		test
24 			(REQUIRE( result ))
25 			(REQUIRE( value == "hello" ));
26 	}
27 	value = "";
28 	{
29 		const char* exec_args[] = { "TestApp", "hello" };
30 		auto result = cli.parse( { 2, exec_args } );
31 		test
32 			(REQUIRE( result ))
33 			(REQUIRE( value == "hello" ));
34 	}
35 	value = "";
36 	{
37 		std::vector<const char*> exec_args { "TestApp", "hello" };
38 		auto result = cli.parse( args( exec_args.begin(), exec_args.end() ) );
39 		test
40 			(REQUIRE( result ))
41 			(REQUIRE( value == "hello" ));
42 	}
43 	value = "";
44 	{
45 		std::vector<const char*> exec_args { "TestApp", "hello" };
46 		auto result = cli.parse( { exec_args.begin(), exec_args.end() } );
47 		test
48 			(REQUIRE( result ))
49 			(REQUIRE( value == "hello" ));
50 	}
51 
52 	return test;
53 }
54