Project

colin

0.0
No commit activity in last 3 years
No release in over 3 years
COmmand Line INterface.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
>= 0
~> 10.0
 Project Readme

CoLIn

Command Line Interface.

Usage

Colin's main focus is to parse command line arguments, but it's not constrained by it.

You can parse any array and get an options hash back.

To parse an array, just pass it as the only argument to Colin::Parser#new.

Let's see an example:

  require "colin"
  
  args = %w[first --name=Federico --age 100 second -y 2015 -f -nnumber]
  
  cli = Colin::Parser.new(args)
  
  cli.options
  # => {:name=>"Federico", :age=>100, :y=>2015, :f=>true, :n=>"number"}
  
  cli.args
  # => ["first", "second"]

If you want to assign names to the remaining arguments, you can call the #named_options method.

It receives an array with the names for the remaining options and it removes as many remaining options as elements there are on the array.

  require "colin"
  
  args = %w[first --name=Federico --age 100 second -y 2015 -f -nnumber third]
  
  cli = Colin::Parser.new(args).named_options([:do, :dont])
  
  cli.options
  # => {:name=>"Federico",
  #     :age=>100,
  #     :y=>2015,
  #     :f=>true,
  #     :n=>"number",
  #     :do=>"first",
  #     :dont=>"second"}
  
  cli.args
  # => ["third"]

Installation

Add this line to your application's Gemfile:

gem 'colin'

And then execute:

$ bundle

Or install it yourself as:

$ gem install colin

Contributing

  1. Fork it ( https://github.com/[my-github-username]/colin/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request