diff --git a/CHANGELOG.md b/CHANGELOG.md index cf1fb251..a9f92e63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Version 1.2 (in progress) +* The name string can now contain spaces around commas [#29](https://github.com/CLIUtils/CLI11/pull/29) * `set_default_str` now only sets string, and `set_default_val` will evaluate the default string given [#26](https://github.com/CLIUtils/CLI11/issues/26) * Required positionals now take priority over subcommands [#23](https://github.com/CLIUtils/CLI11/issues/23) * Extra requirements enforced by Travis diff --git a/include/CLI/App.hpp b/include/CLI/App.hpp index cdb91abc..dfec4a4a 100644 --- a/include/CLI/App.hpp +++ b/include/CLI/App.hpp @@ -23,6 +23,13 @@ #include "CLI/StringTools.hpp" #include "CLI/TypeTools.hpp" +#define CLI11_PARSE(app,argc,argv) \ + try { \ + (app).parse((argc),(argv)); \ + } catch(const CLI::ParseError &e) { \ + return (app).exit(e); \ + } + namespace CLI { namespace detail { diff --git a/tests/AppTest.cpp b/tests/AppTest.cpp index c535f943..2ddb4be7 100644 --- a/tests/AppTest.cpp +++ b/tests/AppTest.cpp @@ -260,7 +260,6 @@ TEST_F(TApp, Positionals) { EXPECT_EQ("thing2", posit2); } - TEST_F(TApp, ForcedPositional) { std::vector posit; auto one = app.add_flag("--one"); diff --git a/tests/CreationTest.cpp b/tests/CreationTest.cpp index 8f1a7337..a1c7b9c7 100644 --- a/tests/CreationTest.cpp +++ b/tests/CreationTest.cpp @@ -231,23 +231,20 @@ TEST_F(TApp, CheckNameNoCase) { EXPECT_TRUE(pos2->check_name("pos2")); } - TEST_F(TApp, PreSpaces) { int x; auto myapp = app.add_option(" -a, --long, other", x); - + EXPECT_TRUE(myapp->check_lname("long")); EXPECT_TRUE(myapp->check_sname("a")); EXPECT_TRUE(myapp->check_name("other")); - } TEST_F(TApp, AllSpaces) { int x; auto myapp = app.add_option(" -a , --long , other ", x); - + EXPECT_TRUE(myapp->check_lname("long")); EXPECT_TRUE(myapp->check_sname("a")); EXPECT_TRUE(myapp->check_name("other")); - }