mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-05-03 14:03:52 +00:00
Adding testing for required subcommands
This commit is contained in:
parent
2ddc7d4346
commit
537aa3aa5d
@ -1,9 +1,9 @@
|
|||||||
## Version 0.5 (in progress)
|
## 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.
|
* Added printout of ini file text given parsed options, skips flags.
|
||||||
* Support for quotes and spaces in ini files
|
* 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
|
## Version 0.4
|
||||||
|
|
||||||
|
@ -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.
|
* Evaluate compatibility with [ROOT](https://root.cern.ch)'s TApplication object.
|
||||||
* Add way for subclasses to return remaining options rather than throwing error
|
* 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.
|
* 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.
|
See the [changelog](./CHANGELOG.md) or [GitHub releases](https://github.com/henryiii/CLI11/releases) for details.
|
||||||
|
|
||||||
|
@ -104,3 +104,18 @@ TEST(THelp, Excludes) {
|
|||||||
EXPECT_THAT(help, HasSubstr("Excludes: --op1"));
|
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"));
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -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 {
|
struct SubcommandProgram : public TApp {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user