Skip to content

Commit

Permalink
[#1063][#1064] minor improvements; added test; update RELEASE-NOTES.md
Browse files Browse the repository at this point in the history
  • Loading branch information
remkop committed May 28, 2020
1 parent 4e14674 commit 9cc6b1a
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 1 deletion.
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ When abbreviated options are enabled, user input `-AB` will match the long `-Aaa
* [#1068] Enhancement: Make `ParserSpec::toString` output settings in alphabetic order.
* [#1069] Enhancement: Debug output should show `optionsCaseInsensitive` and `subcommandsCaseInsensitive` settings.
* [#1070] Enhancement: Code cleanup: removed redundant modifiers and initializations, unused variables, incorrect javadoc references, and more. Thanks to [NewbieOrange](https://github.com/NewbieOrange) for the pull request.
* [#1063][#1064] `ManPageGenerator` now correctly excludes hidden options, parameters, and subcommands from man page generation. Thanks to [Brian Demers](https://github.com/bdemers) for the pull request.
* [#1065] Bugfix: With a `List<>` option in `@ArgGroup`, group incorrectly appears twice in the synopsis. Thanks to [kap4lin](https://github.com/kap4lin) for raising this.
* [#1067] Bugfix: `ParserSpec::initFrom` was not copying `useSimplifiedAtFiles`.
* [#1054] Bugfix: option-parameter gets lost in Argument Groups. Thanks to [waacc-gh](https://github.com/waacc-gh) for raising this.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ static void genOptions(PrintWriter pw, CommandSpec spec) {
List<ArgGroupSpec> groups = optionListGroups(spec);
for (ArgGroupSpec group : groups) { options.removeAll(group.options()); }

if (spec.options().isEmpty()) {
if (options.isEmpty()) {
return;
}
pw.printf("// tag::picocli-generated-man-section-options[]%n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,39 @@ class MyApp {
assertEquals(expected, sw.toString());
}

@Test
public void testHiddenOptions() throws IOException {

@Command(name = "testHiddenOptions",
version = {
"Versioned Command 1.0",
"Picocli " + picocli.CommandLine.VERSION,
"JVM: ${java.version} (${java.vendor} ${java.vm.name} ${java.vm.version})",
"OS: ${os.name} ${os.version} ${os.arch}"},
description = "This app does great things."
)
class MyApp {
@Option(names = {"-o", "--output"}, hidden = true, description = "Output location full path.")
File outputFolder;

@Option(names = {"--hidden-test"}, hidden = true)
File hidden;

@Parameters(hidden = true)
List<String> values;
}

StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw); //System.out, true
ManPageGenerator.writeSingleManPage(pw, new CommandLine(new MyApp()).getCommandSpec());
pw.flush();

String expected = read("/testHiddenOptions.manpage.adoc");
expected = expected.replace("\r\n", "\n");
expected = expected.replace("\n", System.getProperty("line.separator"));
assertEquals(expected, sw.toString());
}

private String read(String resource) throws IOException {
return readAndClose(getClass().getResourceAsStream(resource));
}
Expand Down
33 changes: 33 additions & 0 deletions picocli-codegen/src/test/resources/testHiddenOptions.manpage.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// tag::picocli-generated-full-manpage[]
// tag::picocli-generated-man-section-header[]
:doctype: manpage
:revnumber: Versioned Command 1.0
:manmanual: TestHiddenOptions Manual
:mansource: Versioned Command 1.0
:man-linkstyle: pass:[blue R < >]
= testHiddenOptions(1)

// end::picocli-generated-man-section-header[]

// tag::picocli-generated-man-section-name[]
== Name

testHiddenOptions - This app does great things.

// end::picocli-generated-man-section-name[]

// tag::picocli-generated-man-section-synopsis[]
== Synopsis

*testHiddenOptions*

// end::picocli-generated-man-section-synopsis[]

// tag::picocli-generated-man-section-description[]
== Description

This app does great things.

// end::picocli-generated-man-section-description[]

// end::picocli-generated-full-manpage[]

0 comments on commit 9cc6b1a

Please sign in to comment.