From 262436e679ba283b543836cc3cd01248abe6fb82 Mon Sep 17 00:00:00 2001 From: Evelin Aasna Date: Tue, 22 Feb 2022 13:31:37 +0100 Subject: [PATCH 1/2] [FIX, TEST] flag default patch and unit tests --- include/sharg/argument_parser.hpp | 8 ++- include/sharg/detail/format_parse.hpp | 2 +- include/sharg/exceptions.hpp | 1 + .../argument_parser_design_error_test.cpp | 57 +++++++++-------- test/unit/detail/format_help_test.cpp | 4 +- test/unit/detail/format_html_test.cpp | 2 +- test/unit/detail/format_man_test.cpp | 2 +- test/unit/detail/version_check_test.hpp | 4 +- test/unit/format_parse_test.cpp | 62 +++++++++++++------ 9 files changed, 90 insertions(+), 52 deletions(-) diff --git a/include/sharg/argument_parser.hpp b/include/sharg/argument_parser.hpp index fa790f31..0b30c8e8 100644 --- a/include/sharg/argument_parser.hpp +++ b/include/sharg/argument_parser.hpp @@ -251,11 +251,14 @@ class argument_parser /*!\brief Adds a flag to the sharg::argument_parser. * - * \param[in, out] value The variable in which to store the given command line argument. + * \param[in, out] value The variable which shows if the flag is turned off (default) or on. * \param[in] short_id The short identifier for the flag (e.g. 'i'). * \param[in] long_id The long identifier for the flag (e.g. "integer"). * \param[in] desc The description of the flag to be shown in the help page. * \param[in] spec Advanced flag specification, see sharg::option_spec. + * + * \throws sharg::design_error + * */ void add_flag(bool & value, char const short_id, @@ -263,6 +266,9 @@ class argument_parser std::string const & desc, option_spec const spec = option_spec::standard) { + if (value) + throw design_error("A flag's default value must be false."); + verify_identifiers(short_id, long_id); // copy variables into the lambda because the calls are pushed to a stack // and the references would go out of scope. diff --git a/include/sharg/detail/format_parse.hpp b/include/sharg/detail/format_parse.hpp index 6062fc6c..2b1ddf5d 100644 --- a/include/sharg/detail/format_parse.hpp +++ b/include/sharg/detail/format_parse.hpp @@ -718,7 +718,7 @@ class format_parse : public format_base /*!\brief Handles command line flags, whether they are set or not. * - * \param[out] value The variable in which to store the given command line argument. + * \param[out] value The variable which shows if the flag is turned off (default) or on. * \param[in] short_id The short identifier for the flag (e.g. 'i'). * \param[in] long_id The long identifier for the flag (e.g. "integer"). * diff --git a/include/sharg/exceptions.hpp b/include/sharg/exceptions.hpp index 94a97be9..af3d24a1 100644 --- a/include/sharg/exceptions.hpp +++ b/include/sharg/exceptions.hpp @@ -138,6 +138,7 @@ class validation_error : public argument_parser_error * * - Reuse of a short or long identifier (must be unique) * - Both identifiers must not be empty (one is ok) + * - Flag default value must be false */ class design_error : public argument_parser_error { diff --git a/test/unit/argument_parser_design_error_test.cpp b/test/unit/argument_parser_design_error_test.cpp index b6a6e136..7e08c12f 100644 --- a/test/unit/argument_parser_design_error_test.cpp +++ b/test/unit/argument_parser_design_error_test.cpp @@ -44,57 +44,64 @@ TEST(parse_test, design_error) EXPECT_THROW(parser3.add_option(option_value, '\0', "", "oh oh all is empty."), sharg::design_error); - bool flag_value; + bool true_value{true}; - // short flag + // default true sharg::argument_parser parser4{"test_parser", 1, argv}; - parser4.add_flag(flag_value, 'i', "int1", "this is an int option."); - EXPECT_THROW(parser4.add_flag(flag_value, 'i', "int2", "oh oh another id."), + EXPECT_THROW(parser4.add_flag(true_value, 'i', "int", "oh oh default is true."), sharg::design_error); - // long flag + bool flag_value{false}; + + // short flag sharg::argument_parser parser5{"test_parser", 1, argv}; - parser5.add_flag(flag_value, 'i', "int", "this is an int option."); - EXPECT_THROW(parser5.add_flag(flag_value, 'a', "int", "oh oh another id."), + parser5.add_flag(flag_value, 'i', "int1", "this is an int option."); + EXPECT_THROW(parser5.add_flag(flag_value, 'i', "int2", "oh oh another id."), sharg::design_error); - // empty identifier + // long flag sharg::argument_parser parser6{"test_parser", 1, argv}; - EXPECT_THROW(parser6.add_flag(flag_value, '\0', "", "oh oh another id."), + parser6.add_flag(flag_value, 'i', "int", "this is an int option."); + EXPECT_THROW(parser6.add_flag(flag_value, 'a', "int", "oh oh another id."), + sharg::design_error); + + // empty identifier + sharg::argument_parser parser7{"test_parser", 1, argv}; + EXPECT_THROW(parser7.add_flag(flag_value, '\0', "", "oh oh another id."), sharg::design_error); // positional option not at the end const char * argv2[] = {"./argument_parser_test", "arg1", "arg2", "arg3"}; std::vector vec; - sharg::argument_parser parser7{"test_parser", 4, argv2}; - parser7.add_positional_option(vec, "oh oh list not at the end."); - EXPECT_THROW(parser7.add_positional_option(option_value, "desc."), sharg::design_error); + sharg::argument_parser parser8{"test_parser", 4, argv2}; + parser8.add_positional_option(vec, "oh oh list not at the end."); + EXPECT_THROW(parser8.add_positional_option(option_value, "desc."), sharg::design_error); // using h, help, advanced-help, and export-help - sharg::argument_parser parser8{"test_parser", 1, argv}; - EXPECT_THROW(parser8.add_option(option_value, 'h', "", "-h is bad."), + sharg::argument_parser parser9{"test_parser", 1, argv}; + EXPECT_THROW(parser9.add_option(option_value, 'h', "", "-h is bad."), sharg::design_error); - EXPECT_THROW(parser8.add_option(option_value, '\0', "help", "help is bad."), + EXPECT_THROW(parser9.add_option(option_value, '\0', "help", "help is bad."), sharg::design_error); - EXPECT_THROW(parser8.add_option(option_value, '\0', "advanced-help", + EXPECT_THROW(parser9.add_option(option_value, '\0', "advanced-help", "advanced-help is bad"), sharg::design_error); - EXPECT_THROW(parser8.add_option(option_value, '\0', "export-help", + EXPECT_THROW(parser9.add_option(option_value, '\0', "export-help", "export-help is bad"), sharg::design_error); // using one-letter long identifiers. - sharg::argument_parser parser9{"test_parser", 1, argv}; - EXPECT_THROW(parser9.add_option(option_value, 'y', "z", "long identifier is one letter"), + sharg::argument_parser parser10{"test_parser", 1, argv}; + EXPECT_THROW(parser10.add_option(option_value, 'y', "z", "long identifier is one letter"), sharg::design_error); - EXPECT_THROW(parser9.add_flag(flag_value, 'y', "z", "long identifier is one letter"), + EXPECT_THROW(parser10.add_flag(flag_value, 'y', "z", "long identifier is one letter"), sharg::design_error); // using non-printable characters - sharg::argument_parser parser10{"test_parser", 1, argv}; - EXPECT_THROW(parser10.add_option(option_value, '\t', "no\n", "tab and newline don't work!"), + sharg::argument_parser parser11{"test_parser", 1, argv}; + EXPECT_THROW(parser11.add_option(option_value, '\t', "no\n", "tab and newline don't work!"), sharg::design_error); - EXPECT_THROW(parser10.add_flag(flag_value, 'i', "no\n", "tab and newline don't work!"), + EXPECT_THROW(parser11.add_flag(flag_value, 'i', "no\n", "tab and newline don't work!"), sharg::design_error); - EXPECT_THROW(parser10.add_flag(flag_value, 'a', "-no", "can't start long_id with a hyphen"), + EXPECT_THROW(parser11.add_flag(flag_value, 'a', "-no", "can't start long_id with a hyphen"), sharg::design_error); } @@ -116,7 +123,7 @@ TEST(parse_test, parse_called_twice) TEST(parse_test, subcommand_argument_parser_error) { - bool flag_value{}; + bool flag_value{false}; // subcommand parsing was not enabled on construction but get_sub_parser() is called { diff --git a/test/unit/detail/format_help_test.cpp b/test/unit/detail/format_help_test.cpp index 3b3b0709..b522233a 100644 --- a/test/unit/detail/format_help_test.cpp +++ b/test/unit/detail/format_help_test.cpp @@ -13,7 +13,7 @@ std::string std_cout; std::string expected; int option_value{5}; -bool flag_value{}; +bool flag_value{false}; std::vector pos_opt_value{}; const char * argv0[] = {"./help_add_test --version-check false"}; const char * argv1[] = {"./help_add_test --version-check false", "-h"}; @@ -292,7 +292,7 @@ TEST(help_page_printing, advanced_options) { int32_t option_value{5}; uint8_t another_option_value{2}; - bool flag_value{}; + bool flag_value{false}; auto set_up = [&option_value, &flag_value, &another_option_value] (sharg::argument_parser & parser) { diff --git a/test/unit/detail/format_html_test.cpp b/test/unit/detail/format_html_test.cpp index 63046a98..87db32cc 100644 --- a/test/unit/detail/format_html_test.cpp +++ b/test/unit/detail/format_html_test.cpp @@ -70,7 +70,7 @@ TEST(html_format, full_information_information) std::string my_stdout; std::string expected; int option_value{5}; - bool flag_value; + bool flag_value{false}; int8_t non_list_pos_opt_value{1}; std::vector list_pos_opt_value{}; diff --git a/test/unit/detail/format_man_test.cpp b/test/unit/detail/format_man_test.cpp index e0d4b081..22f2ccee 100644 --- a/test/unit/detail/format_man_test.cpp +++ b/test/unit/detail/format_man_test.cpp @@ -13,7 +13,7 @@ struct format_man_test : public ::testing::Test { int option_value{5}; - bool flag_value{}; + bool flag_value{false}; int8_t non_list_pos_opt_value{1}; std::vector list_pos_opt_value{}; std::string my_stdout{}; diff --git a/test/unit/detail/version_check_test.hpp b/test/unit/detail/version_check_test.hpp index cd774256..f85977d4 100644 --- a/test/unit/detail/version_check_test.hpp +++ b/test/unit/detail/version_check_test.hpp @@ -114,7 +114,7 @@ struct version_check : public ::testing::Test parser.info.version = "2.3.4"; // In case we don't want to specify --version-check but avoid that short help format will be set (no arguments) - bool dummy{}; + bool dummy{false}; parser.add_flag(dummy, 'f', "dummy-flag", "A dummy flag."); testing::internal::CaptureStdout(); @@ -313,7 +313,7 @@ TEST_F(version_check, environment_variable_set) sharg::argument_parser parser{app_name, 2, argv}; parser.info.version = "2.3.4"; - bool dummy{}; + bool dummy{false}; parser.add_flag(dummy, 'f', "dummy-flag", "A dummy flag."); testing::internal::CaptureStdout(); diff --git a/test/unit/format_parse_test.cpp b/test/unit/format_parse_test.cpp index 04e44de9..8959ccf2 100644 --- a/test/unit/format_parse_test.cpp +++ b/test/unit/format_parse_test.cpp @@ -73,12 +73,12 @@ TEST(parse_type_test, add_option_long_id) TEST(parse_type_test, add_flag_short_id_single) { bool option_value1{false}; - bool option_value2{true}; + bool option_value2{false}; - const char * argv[] = {"./argument_parser_test", "-t"}; + const char * argv[] = {"./argument_parser_test", "-f"}; sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; - parser.add_flag(option_value1, 't', "true-flag", "this is a flag."); - parser.add_flag(option_value2, 'f', "false-flag", "this is a flag."); + parser.add_flag(option_value1, 'f', "flag", "this is a flag."); + parser.add_flag(option_value2, 'a', "another-flag", "this is a flag."); testing::internal::CaptureStderr(); EXPECT_NO_THROW(parser.parse()); @@ -90,16 +90,16 @@ TEST(parse_type_test, add_flag_short_id_single) TEST(parse_type_test, add_flag_short_id_multiple) { bool option_value1{false}; - bool option_value2{true}; + bool option_value2{false}; bool option_value3{false}; bool option_value4{false}; - const char * argv[] = {"./argument_parser_test", "-tab"}; + const char * argv[] = {"./argument_parser_test", "-fbc"}; sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; - parser.add_flag(option_value1, 't', "true-flag", "this is a flag."); - parser.add_flag(option_value2, 'f', "false-flag", "this is a flag."); - parser.add_flag(option_value3, 'a', "additional-flag", "this is a flag."); - parser.add_flag(option_value4, 'b', "another-flag", "this is a flag."); + parser.add_flag(option_value1, 'f', "flag", "this is a flag."); + parser.add_flag(option_value2, 'a', "also-flag", "this is a flag."); + parser.add_flag(option_value3, 'b', "additional-flag", "this is a flag."); + parser.add_flag(option_value4, 'c', "another-flag", "this is a flag."); testing::internal::CaptureStderr(); EXPECT_NO_THROW(parser.parse()); @@ -113,18 +113,18 @@ TEST(parse_type_test, add_flag_short_id_multiple) TEST(parse_type_test, add_flag_long_id) { bool option_value1{false}; - bool option_value2{true}; + bool option_value2{false}; - const char * argv[] = {"./argument_parser_test", "--true-flag"}; + const char * argv[] = {"./argument_parser_test", "--another-flag"}; sharg::argument_parser parser{"test_parser", 2, argv, sharg::update_notifications::off}; - parser.add_flag(option_value1, 't', "true-flag", "this is a flag."); - parser.add_flag(option_value2, 'f', "false-flag", "this is a flag."); + parser.add_flag(option_value1, 'f', "flag", "this is a flag."); + parser.add_flag(option_value2, 'a', "another-flag", "this is a flag."); testing::internal::CaptureStderr(); EXPECT_NO_THROW(parser.parse()); EXPECT_TRUE((testing::internal::GetCapturedStderr()).empty()); - EXPECT_EQ(option_value1, true); - EXPECT_EQ(option_value2, false); + EXPECT_EQ(option_value1, false); + EXPECT_EQ(option_value2, true); } TEST(parse_type_test, add_positional_option) @@ -146,7 +146,7 @@ TEST(parse_type_test, independent_add_order) // testing same command line input different add_* order std::string positional_value; - bool flag_value; + bool flag_value{false}; int option_value; // Order 1: option, flag, positional @@ -163,6 +163,8 @@ TEST(parse_type_test, independent_add_order) EXPECT_EQ(option_value, 2); EXPECT_EQ(flag_value, true); + flag_value = false; // reinstate to default value + // Order 1: flag, option, positional sharg::argument_parser parser2{"test_parser", 5, argv, sharg::update_notifications::off}; parser2.add_flag(flag_value, 'b', "flag", "this is a flag."); @@ -176,6 +178,8 @@ TEST(parse_type_test, independent_add_order) EXPECT_EQ(option_value, 2); EXPECT_EQ(flag_value, true); + flag_value = false; + // Order 1: option, positional, flag sharg::argument_parser parser3{"test_parser", 5, argv, sharg::update_notifications::off}; parser3.add_option(option_value, 'i', "int-option", "this is a int option."); @@ -189,6 +193,8 @@ TEST(parse_type_test, independent_add_order) EXPECT_EQ(option_value, 2); EXPECT_EQ(flag_value, true); + flag_value = false; + // Order 1: flag, positional, option sharg::argument_parser parser4{"test_parser", 5, argv, sharg::update_notifications::off}; parser4.add_flag(flag_value, 'b', "flag", "this is a flag."); @@ -202,6 +208,8 @@ TEST(parse_type_test, independent_add_order) EXPECT_EQ(option_value, 2); EXPECT_EQ(flag_value, true); + flag_value = false; + // Order 1: positional, flag, option sharg::argument_parser parser5{"test_parser", 5, argv, sharg::update_notifications::off}; parser5.add_positional_option(positional_value, "this is a string positional."); @@ -215,6 +223,8 @@ TEST(parse_type_test, independent_add_order) EXPECT_EQ(option_value, 2); EXPECT_EQ(flag_value, true); + flag_value = false; + // Order 1: positional, option, flag sharg::argument_parser parser6{"test_parser", 5, argv, sharg::update_notifications::off}; parser6.add_positional_option(positional_value, "this is a string positional."); @@ -234,7 +244,7 @@ TEST(parse_type_test, independent_cmd_order) // testing different command line order std::string positional_value; - bool flag_value; + bool flag_value{false}; int option_value; // Order 1: option, flag, positional (POSIX conform) @@ -251,6 +261,8 @@ TEST(parse_type_test, independent_cmd_order) EXPECT_EQ(option_value, 2); EXPECT_EQ(flag_value, true); + flag_value = false; // reinstate to default value + // Order 1: flag, option, positional (POSIX conform) const char * argv2[] = {"./argument_parser_test", "-b", "-i", "2", "arg"}; sharg::argument_parser parser2{"test_parser", 5, argv2, sharg::update_notifications::off}; @@ -265,6 +277,8 @@ TEST(parse_type_test, independent_cmd_order) EXPECT_EQ(option_value, 2); EXPECT_EQ(flag_value, true); + flag_value = false; + // Order 1: option, positional, flag const char * argv3[] = {"./argument_parser_test", "-i", "2", "arg", "-b"}; sharg::argument_parser parser3{"test_parser", 5, argv3, sharg::update_notifications::off}; @@ -279,6 +293,8 @@ TEST(parse_type_test, independent_cmd_order) EXPECT_EQ(option_value, 2); EXPECT_EQ(flag_value, true); + flag_value = false; + // Order 1: flag, positional, option const char * argv4[] = {"./argument_parser_test", "-b", "arg", "-i", "2"}; sharg::argument_parser parser4{"test_parser", 5, argv4, sharg::update_notifications::off}; @@ -293,6 +309,8 @@ TEST(parse_type_test, independent_cmd_order) EXPECT_EQ(option_value, 2); EXPECT_EQ(flag_value, true); + flag_value = false; + // Order 1: positional, flag, option const char * argv5[] = {"./argument_parser_test", "arg", "-b", "-i", "2"}; sharg::argument_parser parser5{"test_parser", 5, argv5, sharg::update_notifications::off}; @@ -307,6 +325,8 @@ TEST(parse_type_test, independent_cmd_order) EXPECT_EQ(option_value, 2); EXPECT_EQ(flag_value, true); + flag_value = false; + // Order 1: positional, option, flag const char * argv6[] = {"./argument_parser_test", "arg", "-i", "2", "-b"}; sharg::argument_parser parser6{"test_parser", 5, argv6, sharg::update_notifications::off}; @@ -794,7 +814,7 @@ TEST(parse_test, version_check_option_error) TEST(parse_test, subcommand_argument_parser_success) { - bool flag_value{}; + bool flag_value{false}; std::string option_value{}; // parsing @@ -820,6 +840,8 @@ TEST(parse_test, subcommand_argument_parser_success) EXPECT_EQ("foo", option_value); } + flag_value = false; // reinstate to default value + // top-level help page { const char * argv[]{"./top_level", "-h", "-f", "sub1", "foo"}; @@ -835,6 +857,8 @@ TEST(parse_test, subcommand_argument_parser_success) EXPECT_FALSE(std::string{testing::internal::GetCapturedStdout()}.empty()); } + flag_value = false; + // sub-parser help page { const char * argv[]{"./top_level", "-f", "sub1", "-h"}; From b49c3c21127efe76c6728af39ce87ae694b10ba4 Mon Sep 17 00:00:00 2001 From: Evelin Aasna Date: Tue, 22 Feb 2022 13:32:05 +0100 Subject: [PATCH 2/2] [DOC] Clarify flag documentation. --- doc/tutorial/argument_parser/index.md | 12 ++++++++---- doc/tutorial/argument_parser/small_snippets.cpp | 2 +- doc/tutorial/argument_parser/solution3.cpp | 2 +- doc/tutorial/argument_parser/solution4.cpp | 2 +- doc/tutorial/argument_parser/solution5.cpp | 2 +- doc/tutorial/argument_parser/solution6.cpp | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/doc/tutorial/argument_parser/index.md b/doc/tutorial/argument_parser/index.md index 1da95b23..013b306c 100644 --- a/doc/tutorial/argument_parser/index.md +++ b/doc/tutorial/argument_parser/index.md @@ -20,7 +20,7 @@ This class will give you the following functionality: * Robust parsing of command line arguments. * Simple validation of arguments (e.g. within a range or one of a list of allowed values). * Automatically generated and nicely formatted help screens when your program is called with `--help`. You can also -* export this help to HTML and man pages. +export this help to HTML and man pages. * In the future, you are also able to automatically generate nodes for work flow engines such as KNIME or Galaxy. ## Command line argument terminology @@ -79,12 +79,13 @@ screen. The argument parser checks the following restrictions and throws a sharg::design_error if they are not satisfied: * **Long identifiers**: must be unique, more than one character long, may only contain alphanumeric characters, as well -* as `_`, `-`, or `@`, but never start with `-`. +as `_`, `-`, or `@`, but never start with `-`. * **Short identifiers**: must be unique and consist of only a single letter that is alphanumeric characters, `_` or `@`. -* either the short or long id may be empty but not both at the same time. +Either the short or long id may be empty but not both at the same time. * Only the last positional option may be a list (see [lists](#section_list_positional_options)). * The flag identifiers `-h`, `--help`, `--advanced-help`, `--advanced-help`, `--export-help`, `--version`, `--copyright` -* are predefined and cannot be specified manually or used otherwise. +are predefined and cannot be specified manually or used otherwise. +* **Flags**: value must be false by default. Passing the flag identifier on the command line marks it as true. * The sharg::argument_parser::parse function may only be called once (per parser). ## Input restrictions @@ -204,6 +205,9 @@ Additionally to the variable that will store the value and the description, you identifier. The example above will recognize an option `-n` or `--my-number` given on the command line and expect it to be followed by a value separated only by `=` or space or by nothing at all. +\note Unlike regular options which take id-value pairs, flags are passed as an identifier only. The variable associated +to a flag must be false by default and is switched to true when the flag is present on the command line. + Finally, you can add a flag with the following call: \snippet doc/tutorial/argument_parser/small_snippets.cpp add_flag diff --git a/doc/tutorial/argument_parser/small_snippets.cpp b/doc/tutorial/argument_parser/small_snippets.cpp index cf96c61a..2f4ef2fe 100644 --- a/doc/tutorial/argument_parser/small_snippets.cpp +++ b/doc/tutorial/argument_parser/small_snippets.cpp @@ -36,7 +36,7 @@ parser.add_option(variable, 'n', "my-number", "This is a description."); { sharg::argument_parser parser{"Example-Parser", argc, argv}; //![add_flag] -bool variable{}; +bool variable{false}; parser.add_flag(variable, 'f', "my_flag", "This is a description."); //![add_flag] } diff --git a/doc/tutorial/argument_parser/solution3.cpp b/doc/tutorial/argument_parser/solution3.cpp index d24fec3f..8ee7285a 100644 --- a/doc/tutorial/argument_parser/solution3.cpp +++ b/doc/tutorial/argument_parser/solution3.cpp @@ -60,7 +60,7 @@ struct cmd_arguments std::filesystem::path file_path{}; uint32_t year{}; std::string aggregate_by{"mean"}; - bool header_is_set{}; + bool header_is_set{false}; }; //![program] diff --git a/doc/tutorial/argument_parser/solution4.cpp b/doc/tutorial/argument_parser/solution4.cpp index ae364696..69bdb4d3 100644 --- a/doc/tutorial/argument_parser/solution4.cpp +++ b/doc/tutorial/argument_parser/solution4.cpp @@ -62,7 +62,7 @@ struct cmd_arguments std::filesystem::path file_path{}; std::vector seasons{}; std::string aggregate_by{"mean"}; - bool header_is_set{}; + bool header_is_set{false}; }; void initialise_argument_parser(sharg::argument_parser & parser, cmd_arguments & args) diff --git a/doc/tutorial/argument_parser/solution5.cpp b/doc/tutorial/argument_parser/solution5.cpp index 8af80548..68e5f674 100644 --- a/doc/tutorial/argument_parser/solution5.cpp +++ b/doc/tutorial/argument_parser/solution5.cpp @@ -59,7 +59,7 @@ struct cmd_arguments std::filesystem::path file_path{}; std::vector seasons{}; std::string aggregate_by{"mean"}; - bool header_is_set{}; + bool header_is_set{false}; }; void initialise_argument_parser(sharg::argument_parser & parser, cmd_arguments & args) diff --git a/doc/tutorial/argument_parser/solution6.cpp b/doc/tutorial/argument_parser/solution6.cpp index e71c9114..ac064543 100644 --- a/doc/tutorial/argument_parser/solution6.cpp +++ b/doc/tutorial/argument_parser/solution6.cpp @@ -59,7 +59,7 @@ struct cmd_arguments std::filesystem::path file_path{}; std::vector seasons{}; std::string aggregate_by{"mean"}; - bool header_is_set{}; + bool header_is_set{false}; }; void initialise_argument_parser(sharg::argument_parser & parser, cmd_arguments & args)