safety
safety copied to clipboard
support shell globs with a new command that takes multiple file options
- safety version: NA
- Python version: NA
- Operating System: NA
Description
I'm trying to run safety check -r **/requirements*.txt
but -r
only allows one command
introduce a new command that supports unixy [FILE...]
safety check_requirements [OPTION...] [FILE...]
@graingert thank you for this case. You are right, at this moment -r
allows only one file per option. You need to use -r
option multiple times if you want to pass more files (https://click.palletsprojects.com/en/7.x/options/#multiple-options). There is no [FILE...]
support due to the click
library limitations (we are using this library to parse command line args: https://github.com/pallets/click/issues/484). I added this to our list of upcoming features and bugfixes.
Meanwhile, you can try with this quick workaround: for f in **/requirements*.txt; do safety check -r "$f"; done
@lf1up https://click.palletsprojects.com/en/7.x/arguments/#variadic-arguments it looks like you can pass nargs=-1
now
@graingert at this moment we are using @click.option
almost everywhere. Possible usage of @click.argument
should be considered and tested, because it is not an equivalent (drop-in) replacement.
Just wanted to echo the desire to support variadic options. My use case also involves using shell globs/wildcards within options. I think the OptionEatAll
solution on StackOverflow gets the expected behavior right:
https://stackoverflow.com/questions/48391777/nargs-equivalent-for-options-in-click
Although this is a workable solution, it would be nice to have it supported in the library directly. It feels like quite a natural feature, especially considering variadic arguments.