Giter Site home page Giter Site logo

clap's People

Contributors

mrb avatar patriciomacadden avatar soveran avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

clap's Issues

any object that has #call

Instead of just accepting lambdas, CLAP could be made more flexible by accepting any object that has a #call method. Basically replace:

arity = [flag.arity, 0].max

with:

flag  = flag.method(:call) unless Proc === flag
arity = [flag.arity, 0].max

option aliases and regular expressions

How to do option aliases?

CLAP.run ARGV,
  '-o' => lambda { ... }
  '--output' => lambda { ... }

Where both lambdas are the same is redundant. Of course we could create a variable for it:

output_opt = lambda { ... }

CLAP.run ARGV,
  '-o' => output_opt
  '--output' => output_opt

But perhaps an option array could be supported?

CLAP.run ARGV,
  ['-o', '--output'] => lambda { ... }

Also, I wonder if the option itself could be a regular expression?

CLAP.run ARGV,
  /=/ => lambda { |opt| k, v = opt.split('='); options[k] = v }

I really love the simplicity of this library, btw, so maybe these ideas are not useful enough to warrant the additional complexity. But I figure they are worth some thought.

Clap w/ Help?

I'm wondering how Clap might be extended to support standardized command line help output:

Clap.help "Usage: #{$0} [options]",
  "-a" => "explain a"
  "-b" => "explain b"

Clap.run ARGV,
  "-a" => lambda { |param| ... },
  "-b" => lambda { ... }
  "-h" => Clap.help

?

clap sub-command support?

@soveran Could Clap provide subcommand support like the features in git.
For example:

if I do git add, it will print out help message

Nothing specified, nothing added.
Maybe you wanted to say 'git add .'?

Then I can do git add some_files to add files

To support this feature, maybe clap should support various number of arguments for each flag?

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.