davetron5000 / gli

Make awesome command-line applications the easy way
http://davetron5000.github.io/gli
Apache License 2.0
1.26k stars 102 forks source link

Slurp up unknown flags/switches for use later? #233

Closed rchady closed 3 years ago

rchady commented 8 years ago

Question, I am writing a wrapper to another program. I want to be able to specify X,Y,Z to be switches, and then take any extras that are passed in and use them to the program being wrapped. Is there a way to grab all the flags/switches/args that are not known and use them later on?

davetron5000 commented 8 years ago

The convention in a lot of UNIX apps is to place them after a double dash, like so:

> foo -o outfile.txt -i infile.txt -- -x --bar

So you'd be sending -o and -i flags to foo, and -x and --bar would show up as arguments.

I think GLI will do this given that it's based on OptionParser.

If not, that would be the preferred way to do it and it might be easy enough to add, but give it a try first

rchady commented 8 years ago

Yeah, right now trying something like

bundle exec bin/test_command -- -y

or

bundle exec bin/test_command info -- -y

Results in:

error: Too many arguments for command

or

error: Unknown option -y

davetron5000 commented 3 years ago

Closing in favor of #307