Closed SrslyJosh closed 4 years ago
Oh, simply try prepending your trailing arguments with --
!
Like this:
./myProgram -- arg1 arg2 arg3 arg4...
requiring --
is awkward, since it is counterintuitive for users (i.e. what other commands out there require using --
to pass arguments directly to the exe being run?)
python's argparse allows this with nargs='*'
(or nargs='+'
to specify that at least 1 positional arg is required), it collects all remaining args into a list. So basically it's what flaggy does when --
is specified, but without having to include --
Unless I've misunderstood the documentation, it doesn't seem like it's possible to have an arbitrary number of trailing arguments.
Let's say you want to write your own version of
cat(1)
.Based on the documentation, it seems like I should be able to use
flaggy.TrailingArguments
to get at the list of zero or more input files.Unfortunately, if you actually try to use trailing arguments that aren't declared as positionals, flaggy throws an error:
Flaggy will accept trailing arguments if declared as positionals, but there does not seem to be a way to support an arbitrary number of them--each must be explicitly declared, so you can't actually write a
cat
command that takes an arbitrary number of file arguments.