Closed nilsdeppe closed 3 weeks ago
Sure I can do some of these. A few notes:
If you come from argparse, you might be missing support for setting
nargs
to+
to indicate that at least one argument is required.This is supported by setting
required=True
. However, this should not be used if you can avoid it as we believe scripts should gracefully degrade into becoming noops if a variadic argument is empty. The reason for this is that very often, scripts are invoked with wildcard inputs from the command line and they should not error out if the wildcard is empty.
I just followed this recommendation and find it reasonable, but also got confused sometimes when the number of arguments was empty, so I don't have a strong opinion either way.
X Y
vs X,Y
should be made consistent, yes. It currently isn't because sometimes the dimension is fixed to 2 or 3, so nargs
is used which parses as X Y
, and sometimes the dimension is dynamic so we can't use nargs
but have to parse the argument as a comma-separated list X,Y
and check the dimension later. I haven't decided what to do about this yet (probably just always do X,Y
).Thanks!
Yea I agree with 1. Let's change it.
The reason for this is that very often, scripts are invoked with wildcard inputs from the command line and they should not error out if the wildcard is empty.
That's not how (Bourne shell) wildcards work. They can't be empty.
$ mkdir foo
$ cd foo
$ rm *.c
rm: cannot remove '*.c': No such file or directory
In bash there's an option for it, but I'm struggling to think of a command that actually becomes a noop in that case.
$ shopt -s nullglob
$ rm *.c
rm: missing operand
Try 'rm --help' for more information.
@ctrandrsn and I ran into some confusion when trying to use this feature. Specifically,
spectre plot slice
happily runs with zero h5 files. It should give an error if you give no files.--slice-extent
isX Y
while everything else isX,Y
. Having this be consistent would be nice.--subfile-name
seems to have a default subfile but this isn't document. The HDF5 file we ran on only has 1 subfile so I'm not sure if that's why it could do it. In any case, this should be documented in the help text.--slice-origin
and the other--slice
options are all required because if we didn't specify them all we get an error that they must be specified. Could these be marked as required in the help text?--var
also isn't marked as required but is.