Code Monkey home page Code Monkey logo

Comments (6)

kbrock avatar kbrock commented on August 29, 2024

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

from optimist.

NathanZook avatar NathanZook commented on August 29, 2024

I'll see what I can come up with.

from optimist.

Smarre avatar Smarre commented on August 29, 2024

@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.

from optimist.

NathanZook avatar NathanZook commented on August 29, 2024

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.

from optimist.

NathanZook avatar NathanZook commented on August 29, 2024

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...

from optimist.

kbrock avatar kbrock commented on August 29, 2024

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

Something odd happening in the heads

from optimist.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.