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

GLI does not respect the trailing `--` to stop command line parsing #307

Closed davetron5000 closed 1 month ago

peregrinator commented 3 years ago

Curious as to whether you are planning to implement this or if you have any guidance on where best to take a look at adding this. Right now it's a bit of a blocker for my current use case... Thanks!

davetron5000 commented 3 years ago

Hey, I hadn't thought much about it, but wanted to record it as it was not a bug I expected to exist. Under the covers, GLI uses Ruby's OptionParser which should support this use case, so something must be screwing that up before it gets called. GliOptionParser is the root class that initiates the parsing, but it's kindof a bear

peregrinator commented 3 years ago

I think I had another bug in my code when I first attempted to use the -- as part of my command. I fixed another bug and I believe that I also had arguments set in :strict mode which may also have been part of the reason it wasn't working for me.

Using -- to pass additional arguments to the command appears to be working for me as expected at this point so I think this issue could be closed. It may be worth documenting the use of -- though?

davetron5000 commented 1 month ago

I cannot recreate this. I do think that :strict would affect this , but I was able to make a new app and run:

bin/testapp -s foo -s -- -s blah

In this invocation, -s is set as a global option, foo is the command, -s is a local option, and the args array is ["-s","blah"]. This seems like correct behavior. Closing for now. Re-open with a sample app if still experiencing.