-
Notifications
You must be signed in to change notification settings - Fork 440
Open
Labels
lang: groovyGroovy-relatedGroovy-relatedlang: javaPull requests that update Java codePull requests that update Java codelang: kotlinKotlin-relatedKotlin-relatedlang: scalaScala-relatedScala-relatedtheme: compatibilityIssues related to binary and source backwards compatibilityIssues related to binary and source backwards compatibilitytype: API 🔌
Milestone
Description
Somehow related to #877:
Currently, it is possible to annotate a defaultValue for options and parameters. However, one can specify a string/value only, not multiple values. Fortunately, one can workaround this by using split
on the option/positional parameter definition, this solution has some limitations, however.
Code example that illustrates the issue:
public class DefaultValueMultipleOptions {
public static void main(String... args) {
CommandLine cmd = new CommandLine(new MyFileCommand());
cmd.execute(args);
}
}
@Command( name="myCommand", mixinStandardHelpOptions = true)
class MyFileCommand implements Runnable {
@Parameters(defaultValue = { "default file 1", "default file 2" }) // does not work (yet)
// @Parameters(defaultValue = "default file 1,default file 2", split = ",") // this is workaround
String[] files = { "file 1", "file 2" };
public void run() {
for (String file : files)
System.out.println("File: " + file);
System.out.println(String.format("%s files", files.length));
}
}
As said, this is a low priority enhacement as we have a workaround here.
I just wanted to get the author's opinion on this prior to authoring a PR ;-)
Metadata
Metadata
Assignees
Labels
lang: groovyGroovy-relatedGroovy-relatedlang: javaPull requests that update Java codePull requests that update Java codelang: kotlinKotlin-relatedKotlin-relatedlang: scalaScala-relatedScala-relatedtheme: compatibilityIssues related to binary and source backwards compatibilityIssues related to binary and source backwards compatibilitytype: API 🔌