Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stop_on_unknown doesn't work #17

Open
NathanZook opened this issue Nov 4, 2014 · 6 comments
Open

stop_on_unknown doesn't work #17

NathanZook opened this issue Nov 4, 2014 · 6 comments

Comments

@NathanZook
Copy link
Contributor

Explicit raises are now inside the block. The entire mechanism seems to have been neglected, as it's application is uneven.

@kbrock
Copy link
Member

kbrock commented Jan 5, 2015

@Student Any tests/examples showing how you would like it to work?

@NathanZook
Copy link
Contributor Author

I'll see what I can come up with.

@Smarre
Copy link

Smarre commented Feb 2, 2015

@Student Is ignore_invalid_options the you are searching for?

I don’t know what stop_on_unknown() was for, it seems to be readonly on public API anyway, IMHO at least should be renamed.

@NathanZook
Copy link
Contributor Author

Sorry, I've been sick. (Still am.)

Suppose we have something like this:

  opt :a, :name => 'a', :type => :int
  opt :b, :name => 'b', :type => :int

And an args string:

-a 2 -c 3 -b 5

With stop_on_unknown, we should have a return {a: 2} and no error. With ignore_invalid_options, we should have a return {a: 2, b: 5}.

As for my use case, consider the following:

I have a tool which operates in several different modes. The enactment of any particular mode is complex enough that it might be necessary to debug it. So I might define the type and debug options and process. Part of processing the type is to find out what options are available under the type mode. I am then ready to process the rest of the command line. But what I do not want is for a debug setting that applies to running in some mode to be applied while I'm setting up that mode. It's a lot of noise that the users should never have to endure.

I want stop_on_unknown.

@NathanZook
Copy link
Contributor Author

cat bad_stop.rb:

require 'trollop'

opts = Trollop::options do
  opt :alpha, "The biggest, most important opt"
  stop_on_unknown
end
~/work/trollop ruby bad_stop.rb --beta
Error: unknown argument '--beta'.
Try --help for help.

This looks like a fail somewhere...

@kbrock
Copy link
Member

kbrock commented Feb 26, 2015

@Student thanks - I'll look at this once the tests start passing again.

Something odd happening in the heads

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants