diff --git a/CHANGELOG.md b/CHANGELOG.md index 87fc05ac..609b13c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,9 @@ ## Version 0.5 (in progress) -* Added `require_subcommand` to `App`, to simplify forcing subcommands. Do not "chain" with `add_subcommand`, since that is the subcommand, not the master `App`. Untested. +* Added `require_subcommand` to `App`, to simplify forcing subcommands. Do not "chain" with `add_subcommand`, since that is the subcommand, not the master `App`. * Added printout of ini file text given parsed options, skips flags. * Support for quotes and spaces in ini files -* Support for Windows (added Appveyor) (Still use `--` syntax) +* Fixes to allow support for Windows (added Appveyor) (Use `-`, not `/` syntax) ## Version 0.4 diff --git a/README.md b/README.md index 49862bac..5d7bf8a2 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ This library was built to supply the Application object for the GooFit CUDA/OMP * Evaluate compatibility with [ROOT](https://root.cern.ch)'s TApplication object. * Add way for subclasses to return remaining options rather than throwing error * Chained subcommands are not supported, once a subcommand is given the rest of the options go to that subcommand, rather than allowing multiple subcommands. This is currently intentional behavior, but multiple base level subcommands, like [`Click`](http://click.pocoo.org) supports, might be considered in the future. +* Support case insensitive set and/or subcommands? See the [changelog](./CHANGELOG.md) or [GitHub releases](https://github.com/henryiii/CLI11/releases) for details. diff --git a/tests/HelpTest.cpp b/tests/HelpTest.cpp index 4c8e6315..2f0830b9 100644 --- a/tests/HelpTest.cpp +++ b/tests/HelpTest.cpp @@ -104,3 +104,18 @@ TEST(THelp, Excludes) { EXPECT_THAT(help, HasSubstr("Excludes: --op1")); } +TEST(THelp, Subcom) { + CLI::App app{"My prog"}; + + app.add_subcommand("sub1"); + app.add_subcommand("sub2"); + + std::string help = app.help(); + EXPECT_THAT(help, HasSubstr("Usage: program [OPTIONS] [SUBCOMMAND]")); + + app.require_subcommand(); + + help = app.help(); + EXPECT_THAT(help, HasSubstr("Usage: program [OPTIONS] SUBCOMMAND")); + +} diff --git a/tests/SubcommandTest.cpp b/tests/SubcommandTest.cpp index 9ffe99fd..db1aeb30 100644 --- a/tests/SubcommandTest.cpp +++ b/tests/SubcommandTest.cpp @@ -40,9 +40,21 @@ TEST_F(TApp, Callbacks) { } -// TODO: Add directory test +TEST_F(TApp, RequiredSubCom) { + auto sub1 = app.add_subcommand("sub1"); + auto sub2 = app.add_subcommand("sub2"); + app.require_subcommand(); + EXPECT_THROW(run(), CLI::RequiredError); + + app.reset(); + + args = {"sub1"}; + + EXPECT_NO_THROW(run()); + +} struct SubcommandProgram : public TApp {