Skip to content

Instantly share code, notes, and snippets.

@daharon
Last active May 9, 2019 16:59
Show Gist options
  • Save daharon/e6b303c643c1a286830067e7d848e888 to your computer and use it in GitHub Desktop.
Save daharon/e6b303c643c1a286830067e7d848e888 to your computer and use it in GitHub Desktop.
Double printing of argument group members
Usage: <main class> [--foos=FOO[,FOO...] [--foos=FOO[,FOO...]]... --bars=BAR[,
BAR...] [--bars=BAR[,BAR...]]...]
GROUP --bars=BAR[,BAR...]
--foos=FOO[,FOO...]
Usage: <main class> [--foos=FOO[,FOO...] [--foos=FOO[,FOO...]]... --bars=BAR[,
BAR...] [--bars=BAR[,BAR...]]...]
GROUP --bars=BAR[,BAR...]
--foos=FOO[,FOO...]
import picocli.CommandLine;
import picocli.CommandLine.ArgGroup;
import picocli.CommandLine.Option;
import java.util.List;
public class PicoCliTestJava implements Runnable {
@ArgGroup(heading = "GROUP", exclusive = false)
private Group group;
private static class Group {
@Option(names = {"--foos"},
paramLabel = "FOO",
split = ",",
required = true)
List<String> foos;
@Option(names = {"--bars"},
paramLabel = "BAR",
split = ",",
required = true)
List<String> bars;
}
@Override
public void run() {
CommandLine.usage(this, System.out);
}
public static void main(String[] args) {
CommandLine.run(new PicoCliTestJava(), args);
}
}
import picocli.CommandLine
import picocli.CommandLine.ArgGroup
import picocli.CommandLine.Option
class PicoCliTestKotlin : Runnable {
@ArgGroup(heading = "GROUP", exclusive = false)
private var group: Group = Group()
companion object {
private class Group {
@Option(names = ["--foos"],
paramLabel = "FOO",
split = ",",
required = true)
var foos: MutableList<String> = mutableListOf()
@Option(names = ["--bars"],
paramLabel = "BAR",
split = ",",
required = true)
var bars: MutableList<String> = mutableListOf()
}
}
override fun run() = CommandLine.usage(this, System.out)
}
fun main(args: Array<String>) =
CommandLine.run(PicoCliTestKotlin(), *args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment