Coder Social home page Coder Social logo

Comments (3)

roberts1000 avatar roberts1000 commented on August 30, 2024 1

This is a great improvement and a big help! Thank you taking the time to improve the docs.

from cri.

denisdefreyne avatar denisdefreyne commented on August 30, 2024

option’s argument: parameter defaults to :forbidden.

When an option has a forbidden argument, its value will end up being true. This is intended for flags such as --verbose:

flag :v, :verbose, 'be verbose'
# assuming the command is invoked with --verbose:

p options[:verbose]
# => true

When using multiple: true, all option values end up in an array. For options with required arguments, this means the array ends up containing a list of strings, while for options with forbidden arguments, the array ends up containing a list of trues:

flag :v, :verbose, 'be verbose', multiple: true
# assuming the command is invoked with --verbose --verbose --verbose:

p options[:verbose]
# => [true, true, true]

The documentation is admittedly unclear on :forbidden being the default, and on the array of trues. Will update.

from cri.

denisdefreyne avatar denisdefreyne commented on August 30, 2024

Hi,

I’ve greatly expanded the section on how to define command-line options. It now has an explicit section on argument:, and also comes with a handful of examples. This should make it more understandable.

Let me know what you think!

from cri.

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.