Skip to content

Commit

Permalink
Revert "[remkop#1316] Bugfix: Avoid `DuplicateOptionAnnotationsExcept…
Browse files Browse the repository at this point in the history
…ion` thrown on `mixinStandardHelpOptions` for subcommands when parent has `scope = INHERIT` by `picocli-codegen` annotation processor."

This reverts commit 735f951.
  • Loading branch information
MarkoMackic authored Oct 17, 2021
1 parent 26c1cff commit b4c23fc
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 57 deletions.
1 change: 0 additions & 1 deletion RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Picocli follows [semantic versioning](http://semver.org/).
## <a name="4.6.2-fixes"></a> Fixed issues
* [#1303] Bugfix: Prevent `IllegalArgumentException: argument type mismatch` error in method subcommands with inherited mixed-in standard help options. Thanks to [Andreas Deininger](https://github.com/deining) for raising this.
* [#1300] Bugfix: Avoid spurious warning "Could not set initial value for field boolean" when reusing `CommandLine` with ArgGroup. Thanks to [Yashodhan Ghadge](https://github.com/codexetreme) for raising this.
* [#1316] Bugfix: Avoid `DuplicateOptionAnnotationsException` thrown on `mixinStandardHelpOptions` for subcommands when parent has `scope = INHERIT` by `picocli-codegen` annotation processor. Thanks to [Philippe Charles](https://github.com/charphi) for raising this.
* [#1296] DOC: add Kotlin code samples to user manual; other user manual improvements. Thanks to [Andreas Deininger](https://github.com/deining) for the pull request.
* [#1299] DOC: Link to `IParameterPreprocessor` from `IParameterConsumer` javadoc. Thanks to [Andreas Deininger](https://github.com/deining) for the pull request.
* [#1304] DOC: Manual, chapter '17.9 Inherited Command Attributes': added Kotlin version of code sample. Thanks to [Andreas Deininger](https://github.com/deining) for the pull request.
Expand Down

This file was deleted.

This file was deleted.

8 changes: 3 additions & 5 deletions src/main/java/picocli/CommandLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -7156,11 +7156,9 @@ public CommandSpec negatableOptionTransformer(INegatableOptionTransformer newVal
* @see Command#mixinStandardHelpOptions() */
public CommandSpec mixinStandardHelpOptions(boolean newValue) {
if (newValue) {
if (!mixins.containsKey(AutoHelpMixin.KEY)) { // #1316 avoid DuplicateOptionAnnotationsException
CommandSpec mixin = CommandSpec.forAnnotatedObject(new AutoHelpMixin(), new DefaultFactory());
mixin.inherited = this.inherited();
addMixin(AutoHelpMixin.KEY, mixin);
}
CommandSpec mixin = CommandSpec.forAnnotatedObject(new AutoHelpMixin(), new DefaultFactory());
mixin.inherited = this.inherited();
addMixin(AutoHelpMixin.KEY, mixin);
} else {
CommandSpec helpMixin = mixins.remove(AutoHelpMixin.KEY);
if (helpMixin != null) {
Expand Down
14 changes: 0 additions & 14 deletions src/test/java/picocli/InheritedOptionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -543,18 +543,4 @@ void sub(@Option(names = "-foo") int foo) {
new CommandLine(app).execute("sub", "-foo", "42" );
assertEquals(42, app.subCalled);
}

@Test
public void testIssue1316() {
@CommandLine.Command(
name = "example",
mixinStandardHelpOptions = true,
scope = CommandLine.ScopeType.INHERIT,
subcommands = AutoComplete.GenerateCompletion.class
)
class Example { }

// see also picocli-annotation-processing-tests/src/test/java/picocli/annotation/processing/tests/Issue1316Test.java
new CommandLine(new Example()); // succeeds without error
}
}

0 comments on commit b4c23fc

Please sign in to comment.