Repository navigation
stop parsing flags when -- is provided in command line #734
Description
Activity
Have you tried
catch_all?bahsly.yml
name: download help: Sample minimal application without commands version: 0.1.0 catch_all: true # <= this args: - name: source required: true help: URL to download from - name: target help: "Target filename (default: same as source)" flags: - long: --force short: -f help: Overwrite existing files examples: - download example.com - download example.com ./output -f
output
$ ./download src dest -f -- -anything -else can be here args: - ${args[--force]} = 1 - ${args[source]} = src - ${args[target]} = dest other_args: - ${other_args[*]} = -anything -else can be here - ${other_args[0]} = -anything - ${other_args[1]} = -else - ${other_args[2]} = can - ${other_args[3]} = be - ${other_args[4]} = here
actually i wasn't aware of this flag (or forgot about it). it would help in cases where the author of the script intentionally wants to grab for example a bash command that should be called (like
docker run image cmd...does). however my described usecase is slightly different.example:
name: inspect help: Sample minimal application without commands version: 0.1.0 args: - name: filename required: true help: a file on your disk examples: - inspect file.txt
sometimes regular arguments look like flags as they begin with a
-(for example a actual file which is called-x.yml.). Those files might be created intentionally or by accident sometimes. for something likecatyou would just writecat -- -x.yml. So I'm not talking about having additional args in aother_argsarray, but actually having${args[filename]}="-x.yml"what i mean is: in most clis
--means: stop parsing flags at all and consider everything from here a regular argument and not a flagI see. Assuming I can implement it without changing the
catch_allbehavior - would you be able to test it for your use case using a pre-release / source build?Sure. I'm glad if I can help. Bashly is a great framework I use quite a lot.
Reacted by Danny Ben ShitritIt is implemented in #735
Assuming you have Ruby installed, you can build from source (from the feature branch)
git clone --depth 1 --branch add/end-of-options-delimiter \ https://github.com/bashly-framework/bashly.git cd bashly bundle install bundle exec run gem install
This installs the branch version of Bashly locally.
If you are uncomfortable with this, I will release a pre-release gem.
i ran everything in a ruby docker container and generated my project with it. every worked as i would expect it.
Excellent. Thanks.
I will merge it, and it will be a part of the 2.0.0 release that comes hopefully soon.
Once I merge you can use thedannyben/bashly:edgeimage if you want.Reacted by Stefan HojerVersion 2.0.0 released. Thanks for this issue.
Description
Currently the argument parser doesn't honor a
--in the command line which might be necessary to allow "flag like arguments" to be parsed. (i.e. a regular argument which starts with a-; for example a file name-x).If this breaks existing behaviour I'd like to have this as an option in the
settings.ymlat least, although i don't see much reason why this shouldn't be enabled by default as most gnu based cli's already work this way.