Skip to content

Commit

Permalink
#277 update release notes and user manual for new hidden subcommands …
Browse files Browse the repository at this point in the history
…feature
  • Loading branch information
remkop committed Feb 4, 2018
1 parent 08afcf9 commit 53ef782
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
10 changes: 5 additions & 5 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ No features have been promoted in this picocli release.

## <a name="3.0.0-alpha-1-fixes"></a> Fixed issues

- [#245] API Change: From 3.0, picocli offers an API for programmatic configuration.
- [#144] API Change: Added support for mixins to allow reusing common options, positional parameters, subcommands and command attributes from any object.
- [#245] New Feature: From 3.0, picocli offers an API for programmatic configuration.
- [#144] New Feature: Added support for mixins to allow reusing common options, positional parameters, subcommands and command attributes from any object.
- [#175] New Feature: `autoHelp` attribute to conveniently activate fully automatic help.
- [#262] API Change: new `showDefaultValue` attribute on `@Option` and `@Parameters` gives fine-grained control over which default values to show or hide. Thanks to [ymenager](https://github.com/ymenager) for the request.
- [#268] subcommands can now be annotated with @Command(isHelpCommand = true). If the parser detects this subcommand on the command line, it will not validate the required options or positional parameters of the parent command. Thanks to [ymenager](https://github.com/ymenager) for the request.
- [#277] subcommands can now be hidden in the usage help message
- [#262] New Feature: new `showDefaultValue` attribute on `@Option` and `@Parameters` gives fine-grained control over which default values to show or hide. Thanks to [ymenager](https://github.com/ymenager) for the request.
- [#268] New Feature: new `isHelpCommand` attribute on `@Command`: if the parser detects this subcommand on the command line, it will not validate the required options or positional parameters of the parent command. Thanks to [ymenager](https://github.com/ymenager) for the request.
- [#277] New Feature: new `hidden` attribute on `@Command` to omit the specified subcommand from the usage help message command list of the parent command. Thanks to [pditommaso](https://github.com/pditommaso).

## <a name="3.0.0-alpha-1-deprecated"></a> Deprecations

Expand Down
23 changes: 23 additions & 0 deletions docs/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1835,6 +1835,29 @@ The usage help message for each subcommand is produced by calling `CommandLine.u
For example, see <<Section Headings>> for an example subcommand (`git-commit`), which produces the help message shown
in <<Expanded Example>>.

=== Hidden subcommands

Commands with the `hidden` attribute set to `true` will not be shown in the usage help message of their parent command.

For example, the `bar` subcommand below is annotated as `hidden = true`:

[source,java]
----
@Command(name = "foo", description = "This is a visible subcommand")
class Foo { }
@Command(name = "bar", description = "This is a hidden subcommand", hidden = true)
class Bar { }
@Command(name = "app", subcommands = {Foo.class, Bar.class})
class App { }
----
The usage help message for `App` looks like the below. Note that the `bar` subcommand is not shown:
----
Usage: app
Commands:
foo This is a visible subcommand
----

=== Nested sub-subcommands
The specified object can be an annotated object or a
Expand Down
13 changes: 5 additions & 8 deletions src/test/java/picocli/CommandLineHelpTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3057,21 +3057,18 @@ public void testAutoHelpMixinRunHelpSubcommandWithoutCommand() throws Exception

@Test
public void testUsageTextWithHiddenSubcommand() throws Exception {
@Command(name = "foo", description = "This is a foo sub-command") class Foo { }
@Command(name = "bar", description = "This is a foo sub-command", hidden = true) class Bar { }
@Command(name = "app", abbreviateSynopsis = true) class App { }

CommandLine app = new CommandLine(new App())
.addSubcommand("foo", new Foo())
.addSubcommand("bar", new Bar());
@Command(name = "foo", description = "This is a visible subcommand") class Foo { }
@Command(name = "bar", description = "This is a hidden subcommand", hidden = true) class Bar { }
@Command(name = "app", subcommands = {Foo.class, Bar.class}) class App { }

CommandLine app = new CommandLine(new App(), new InnerClassFactory(this));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
app.usage(new PrintStream(baos));

String expected = format("" +
"Usage: app%n" +
"Commands:%n" +
" foo This is a foo sub-command%n");
" foo This is a visible subcommand%n");
assertEquals(expected, new String(baos.toByteArray(), "UTF-8"));
}

Expand Down

0 comments on commit 53ef782

Please sign in to comment.