Skip to content

Commit

Permalink
Revert "[remkop#1267] Add CommandLine::getFactory accessor for the …
Browse files Browse the repository at this point in the history
…factory"

This reverts commit 0c3f251.
  • Loading branch information
MarkoMackic committed Oct 17, 2021
1 parent f305461 commit 4178b12
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 38 deletions.
2 changes: 0 additions & 2 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ This release contains new features, bug fixes and other enhancements.
* [Vitaly Shukela](https://github.com/vi) raised a bug report: the error message for unmatched positional argument reports an incorrect index when value equals a previously matched argument.
* [drkilikil](https://github.com/drkilikil) raised a bug report: `MissingParameterException` should not be thrown when subcommand has required options and help option is specified on parent command.
* [Lukas Heumos](https://github.com/Zethson) added the picocli-based [cli-java template](https://cookietemple.readthedocs.io/en/latest/available_templates/available_templates.html#cli-java) to CookieTemple.
* [Sualeh Fatehi](https://github.com/sualeh) raised the idea of adding add `CommandLine::getFactory` accessor method.

## What is in this release
Improved Groovy support: this release introduces a new `@PicocliScript2` annotation that adds support for exit codes and `@Command`-annotated methods to define subcommands. Also, from this release, Groovy programs can use closures in the picocli annotations instead of specifying a class.
Expand Down Expand Up @@ -256,7 +255,6 @@ Attributes that are _not_ copied include:
* [#1254] API: Added `ArgSpec::root`: this method returns the original `ArgSpec` for inherited `ArgSpec` objects, and `null` for other `ArgSpec` objects. Thanks to [Daniel Gray](https://github.com/danielthegray) for the pull request.
* [#1256] API: Added `CommandSpec::removeSubcommand` method. Thanks to [Marko Mackic](https://github.com/MarkoMackic) for raising this.
* [#1258] API: Groovy programs can now use closures in the picocli annotations instead of specifying a class. Thanks to [Adrian A.](https://github.com/aadrian) for raising this.
* [#1267] API: Add `CommandLine::getFactory` accessor for the factory. Thanks to [Sualeh Fatehi](https://github.com/sualeh) for the suggestion.
* [#1108] Enhancement: Support `Optional<T>` type for options and positional parameters. Thanks to [Max Rydahl Andersen](https://github.com/maxandersen) for raising this.
* [#1214] Enhancement: Support Map options with key-only (support `-Dkey` as well as `-Dkey=value`). Thanks to [Max Rydahl Andersen](https://github.com/maxandersen) and [David Walluck](https://github.com/dwalluck) for raising this and subsequent discussion.
* [#1260] Enhancement: Support `@Spec`-annotated members in `ArgGroup` classes. Thanks to [Jannick Hemelhof](https://github.com/clone1612) for raising this.
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/picocli/CommandLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,6 @@ public <T> T getCommand() {
return (T) getCommandSpec().userObject();
}

/** Returns the factory that this {@code CommandLine} was constructed with.
* @return the factory that this {@code CommandLine} was constructed with, never {@code null}
* @since 4.6 */
public IFactory getFactory() { return factory; }

/** Returns {@code true} if an option annotated with {@link Option#usageHelp()} was specified on the command line.
* @return whether the parser encountered an option annotated with {@link Option#usageHelp()}.
* @since 0.9.8 */
Expand Down
31 changes: 0 additions & 31 deletions src/test/java/picocli/CommandLineTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3483,35 +3483,4 @@ public void close() throws IOException {
String expected = "[picocli WARN] Could not close picocli.CommandLineTest$2@: java.lang.IllegalStateException: booh!";
assertEquals(expected, systemErrRule.getLog().replaceAll("@.*: java", "@: java"));
}

@Test
public void testGetFactoryDefault1() {
CommandLine cmd = new CommandLine(CompactFields.class);
CommandLine.IFactory dflt = CommandLine.defaultFactory();
assertNotSame(dflt, cmd.getFactory());
assertEquals(dflt.getClass(), cmd.getFactory().getClass());
}

@Test
public void testGetFactoryDefault2() {
CommandLine cmd = new CommandLine(new CompactFields());
CommandLine.IFactory dflt = CommandLine.defaultFactory();
assertNotSame(dflt, cmd.getFactory());
assertEquals(dflt.getClass(), cmd.getFactory().getClass());
}

@Test
public void testGetFactoryCustom() {
CommandLine.IFactory myFactory = new CommandLine.IFactory() {
public <K> K create(Class<K> cls) {
return null;
}
};
CommandLine cmd = new CommandLine(CompactFields.class, myFactory);
assertSame(myFactory, cmd.getFactory());

CommandLine.IFactory dflt = CommandLine.defaultFactory();
assertNotSame(dflt, cmd.getFactory());
assertNotEquals(dflt.getClass(), cmd.getFactory().getClass());
}
}

0 comments on commit 4178b12

Please sign in to comment.