HPInc / HP-Digital-Microfluidics

HP Digital Microfluidics Software Platform and Libraries
MIT License
2 stars 0 forks source link

Allow multi-word quantity command-line arguments #235

Open EvanKirshenbaum opened 5 months ago

EvanKirshenbaum commented 5 months ago

It is very non-intuitive that if you want to specify, say, the clock speed on the command line, you can say --clock-speed 100ms, but you can't say --clock-speed 100 ms. This is especially awkward when using words for units as in --min-time 1day.

I can see a couple of ways to handle this. The kludgier way would be to use nargs="*" for the argument and have ArgParse.parse_arg() do some sort of buffering on the strings it gets to try to figure out whether it got one or two arguments. If we do this, we might have to use a tuple for the metavar to get a reasonable usage message (i.e., one that didn't imply that we allowed multiple values when we only allow one). In any case, this would have to be specified on every use of a quantity argument.

The clean way is to define a proprietary action as a subclass of Action that looks at what it gets and decides whether to consume one or two arguments. This would also allow it to provide a format_usage() function that will allow usage messages to get the message across. This will probably also allow this to play well with nargs (or else to have several actions that mimic the various nargs values) as well as to have actions for normal actions such as append or extend.

Migrated from internal repository. Originally created by @EvanKirshenbaum on Feb 04, 2023 at 3:42 PM PST.
EvanKirshenbaum commented 5 months ago

This would also be useful for XYCoord parameters such as those that would be wanted for --hole 15 4 (#248).

Migrated from internal repository. Originally created by @EvanKirshenbaum on Feb 16, 2023 at 10:22 AM PST.