1 /*
2 Copyright 2020-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 <sstream>
9 #include <iostream>
10 #include <lyra/lyra.hpp>
11 #include "mini_test.hpp"
12 
main(int,const char **)13 int main(int, const char**)
14 {
15     using namespace lyra;
16     bfg::mini_test::scope test;
17 
18 	{
19 		bool show_help = false;
20 		std::string message;
21 		// Ex: <exe> --repeat=10 "Hello world."
22 		auto cli
23 			= lyra::cli()
24 			| help(show_help)
25 			| lyra::arg(message, "++message++").help("**message**");
26 		std::ostringstream help_text;
27 		help_text << cli ;
28 		test
29 			(REQUIRE(help_text.str().find("**message**") != std::string::npos))
30 			(REQUIRE(help_text.str().find("[<++message++>]") != std::string::npos));
31 	}
32 
33 	{
34 		bool show_help = false;
35 		std::string message;
36 		// Ex: <exe> --repeat=10 "Hello world."
37 		auto cli
38 			= lyra::cli()
39 			| help(show_help)
40 			| lyra::arg(message, "++message++").help("**message**").required();
41 		std::ostringstream help_text;
42 		help_text << cli ;
43 		test
44 			(REQUIRE(help_text.str().find("**message**") != std::string::npos))
45 			(REQUIRE(help_text.str().find("[<++message++>]") == std::string::npos))
46 			(REQUIRE(help_text.str().find("++message++") != std::string::npos));
47 	}
48 
49 	return test;
50 }
51