Open camall3n opened 4 years ago
I would prefer to switch the whole interface to '+'
I have two main issues with using '+' globally:
I remember that we settled on '+' for prelaunch because we wanted a way to avoid conflicts between user-script arguments and prelaunch arguments. I still wonder if there's a way to achieve that while retaining the normal '--arg' syntax...?
I dunno, I feel like one can get used to it real quick. What's confusing is having two different versions simultaneously.
As for another way to accomplish the not-conflating thing, I'm open to any method that's not significantly more complicated.
Here's a sketch of a solution. We make multiple passes through the arguments. We continue to use both +
and --
prefixes for prelaunch only, and leave the other subcommands unchanged with --
only. However, most of the prelaunch options switch to --
; only the +arg
, +pos-arg
and +flag
prelaunch options would continue to use +
.
Input:
onager prelaunch --jobname myjob --command mycommand +arg --some-arg 1 2 +arg --other-arg foo bar +flag
We initially modify the prelaunch
subcommand to prelaunch+
, so it gets parsed by the +
parser.
if sys.argv[1] == 'prelaunch':
sys.argv[1] = 'prelaunch+'
First pass; look for +
commands:
> args, other_args = parse_args()
> args
Namespace(
arg=[['--some-arg', '1', '2'], ['--other-arg', 'foo', 'bar']],
flag=['--some-flag']
)
> other_args
['--jobname', 'myjob', '--command', 'mycommand']
Second pass; look for --
commands and add to existing namespace:
> parse_args(['prelaunch-'] + other_args, namespace=args)
> args
Namespace(
arg=[['--some-arg', '1', '2'], ['--other-arg', 'foo', 'bar']],
flag=['--some-flag'],
command='mycommand',
jobname='myjobname'
)
This would require modifying the help
subcommand to properly show both types of input args (+
and --
), but I suspect that's possible. And even if it needs to be done by hand, it's worth it to have a unified interface.
Currently the prelaunch command args use '+' prefixes, whereas the rest of the library uses '--' prefixes. This is confusing.
Cam: "+arg has a nice intuitive meaning for me, whereas +jobname does not." Neev: "Yeah. But I'd rather have consistency."
Neev: "I catch myself using + by accident in launch too."