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 "mini_test.hpp"
9 #include <lyra/lyra.hpp>
10 
main()11 int main()
12 {
13 	using namespace lyra;
14 	bfg::mini_test::scope test;
15 
16 	{
17 		int number = 0;
18 		auto cli = lyra::cli() | opt(number, "number");
19 		auto result = cli.parse({ "TestApp", "-o", "filename" });
20 		test(REQUIRE(!result));
21 		test(REQUIRE(result.message() == "No options supplied to opt"));
22 	}
23 	{
24 		int number = 0;
25 		auto cli = lyra::cli() | opt(number, "number")[""];
26 		auto result = cli.parse({ "TestApp", "-o", "filename" });
27 		test(REQUIRE(!result));
28 		test(REQUIRE(result.message() == "Option name cannot be empty"));
29 	}
30 	{
31 		int number = 0;
32 		auto cli = lyra::cli() | opt(number, "number")["invalid"];
33 		auto result = cli.parse({ "TestApp", "-o", "filename" });
34 		test(REQUIRE(!result));
35 		test(REQUIRE(
36 			result.message().find("Option name must begin with '-'")
37 			== 0));
38 	}
39 
40 	return test;
41 }
42