Code Monkey home page Code Monkey logo

Comments (3)

Fryguy avatar Fryguy commented on August 29, 2024

There is special logic for flags starting with 'no' to account for
supporting negation of normal flags. I think you can specify a default to
get your desired affect. Another option is to code for the positive and
set a default.

See this blog post for more detail.
http://masanjin.net/blog/trollop-2.0-released
Does that help explain it?
On Jan 26, 2015 9:48 PM, "rlpowell" [email protected] wrote:

Given:

parser = Trollop::Parser.new do
opt :silent, %q{Causes the script to not ask any questions, instead all questions turn into email + abort; used by cron}, :short => 's'
opt :region, %q{Causes the script only work on the listed region}, :short => 'r', :type => String
opt :noinst, %q{Causes the script to skip the checking of all instances}, :short => 'i'
end

Running it with -i gives us:

{:silent=>false,
:region=>nil,
:noinst=>true,
:help=>false,
:noinst_given=>true}

However, given:

parser = Trollop::Parser.new do
opt :silent, %q{Causes the script to not ask any questions, instead all questions turn into email + abort; used by cron}, :short => 's'
opt :region, %q{Causes the script only work on the listed region}, :short => 'r', :type => String
opt :no_instances, %q{Causes the script to skip the checking of all instances}, :short => 'i'
end

which is what I had originally, running it with -i gives:

{:silent=>false,
:region=>nil,
:no_instances=>false,
:help=>false,
:no_instances_given=>true}

which strikes me as wrong.


Reply to this email directly or view it on GitHub
#37.

from optimist.

rlpowell avatar rlpowell commented on August 29, 2024

That does, although now the bug is "this doesn't seem to be mentioned in the documentation anywhere" :)

I'm looking at http://www.rubydoc.info/gems/trollop/2.1.1 and http://www.rubydoc.info/gems/trollop/2.1.1/Trollop/Parser

from optimist.

kbrock avatar kbrock commented on August 29, 2024

@ripowell thanks for bringing this up. Any suggestions for the docs?

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.