-
Notifications
You must be signed in to change notification settings - Fork 441
Closed
Labels
status: invalid 😶An issue that we don't feel is validAn issue that we don't feel is validtheme: parserAn issue or change related to the parserAn issue or change related to the parser
Description
If this is the same request as #454 then the issue can be closed.
I am trying to match the gcloud tool which supports repeating arguments. For example:
--device model=Nexus6
--device model=Nexus6
results in two devices. I have the following pico cli code:
@Option(
names = ["--device"], split = ",", description = ["""A list of DIMENSION=VALUE pairs which specify a target
|device to test against. This flag may be repeated to specify multiple devices. The four device dimensions are:
| model, version, locale, and orientation. If any dimensions are omitted, they will use a default value. Omitting
| all of the preceding dimension-related flags will run tests against a single device using defaults for all four
| device dimensions."""]
)
fun deviceMap(map: Map<String, String>?) {
if (map.isNullOrEmpty()) return
val androidDevice = Device(
model = map.getOrDefault("model", defaultAndroidModel),
version = map.getOrDefault("version", defaultAndroidVersion),
locale = map.getOrDefault("locale", defaultLocale),
orientation = map.getOrDefault("orientation", defaultOrientation)
)
if (device == null) device = mutableListOf()
device?.add(androidDevice)
}
var device: MutableList<Device>? = null
When I test the code, only one device is kept:
@Test
fun cli_device_repeat() {
val cli = AndroidRunCommand()
CommandLine(cli).parse(
"--device=model=shamu,version=22,locale=zh_CN,orientation=default " +
"--device=model=shamu,version=22,locale=zh_CN,orientation=default")
val yaml = """
gcloud:
app: $appApk
test: $testApk
"""
val androidArgs = AndroidArgs.load(yaml, cli)
val expectedDevice = Device("shamu", "22", "zh_CN", "default")
val actualDevices = androidArgs.devices
assertThat(actualDevices.size).isEqualTo(2)
assertThat(actualDevices[0]).isEqualTo(expectedDevice)
assertThat(actualDevices[1]).isEqualTo(expectedDevice)
}
Is there no support for repeating commands in picocli?
Metadata
Metadata
Assignees
Labels
status: invalid 😶An issue that we don't feel is validAn issue that we don't feel is validtheme: parserAn issue or change related to the parserAn issue or change related to the parser