-
Notifications
You must be signed in to change notification settings - Fork 418
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#1773] Enhancement: Applications can improve startup time by setting…
… system property `picocli.disable.closures` to `true` Closes #1773
- Loading branch information
Showing
4 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
picocli-groovy/src/test/groovy/picocli/groovy/ClosureInAnnotationsDisabledTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package picocli.groovy | ||
|
||
import org.junit.AfterClass | ||
import org.junit.BeforeClass | ||
import org.junit.Test | ||
import picocli.CommandLine | ||
import picocli.CommandLine.InitializationException | ||
|
||
class ClosureInAnnotationsDisabledTest { | ||
@BeforeClass | ||
public static void beforeClass() { | ||
System.setProperty("picocli.disable.closures", "true") | ||
} | ||
|
||
@AfterClass | ||
public static void afterClass() { | ||
System.clearProperty("picocli.disable.closures") | ||
} | ||
|
||
|
||
@CommandLine.Command(name = "ClosureDemo", | ||
versionProvider = { {-> ["line1" , "line2"] as String[] } as CommandLine.IVersionProvider }, | ||
defaultValueProvider = {{argSpec -> "some default" } as CommandLine.IDefaultValueProvider} | ||
) | ||
static class ClosureDemo { | ||
@CommandLine.Option(names = '-x', completionCandidates = {["A", "B", "C"]}) | ||
String x | ||
|
||
@CommandLine.Option(names = '-y', | ||
parameterConsumer = {{args, argSpec, commandSpec -> | ||
argSpec.setValue(args.toString() + commandSpec.name()) | ||
args.clear() | ||
} as CommandLine.IParameterConsumer }) | ||
String y | ||
} | ||
|
||
@Test | ||
void testClosureDemo() { | ||
try { | ||
new CommandLine(new ClosureDemo()) | ||
} catch (InitializationException ex) { | ||
String name = ClosureDemo.class.getName() | ||
assert ex.message.startsWith("Cannot instantiate ${name}\$_closure1: the class has no constructor") | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters