colin 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +47 -5
  3. data/colin.gemspec +1 -1
  4. data/lib/colin.rb +1 -0
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7222aa55c17154f596de33d400ed698445c7b623
4
- data.tar.gz: 090d2c27d773f6f894b62b848de35161dd5faae1
3
+ metadata.gz: 0140f7ae2032f04b7c20e60bec743b521c472b03
4
+ data.tar.gz: fa9a91123f70ba5d72fee59c5017ad9728599e67
5
5
  SHA512:
6
- metadata.gz: 5ce2be56fe031d7b79dd5e42d52b3ad2bcd6bb6821076a3f33edb9c6244c891b8730087a35548c0c56a34bc60140829945dd1c81f3d3a1143471ec32451ec1fa
7
- data.tar.gz: 067c6057ce13e7969ef01937403df67c170a87812d8d71c294a10a4f9267eddbf5ba1786b02e455338b9fea9a06b879481074b846b04930ab510b4345635c7ab
6
+ metadata.gz: 7745ec915493d1c79f18ecf5c2be9329e24591a1eede5aa54887e18c2cb6935f71a70fd80dc20169418cc5fd4e3d566119552a20d84b4b81aacf97b913539828
7
+ data.tar.gz: 9c9c305b73c88929b825601279c370651fc4c49a82503812270dfc0e2a7f1fb9b4ac990bf5964a60222851c3b82c60dcae85c6f453d026b9b397a92247ac3f3d
data/README.md CHANGED
@@ -1,12 +1,54 @@
1
- # colin
1
+ # CoLIn
2
2
 
3
- Command Line Interface.
4
-
5
- Nothing to see here yet
3
+ **Co**mmand **L**ine **In**terface.
6
4
 
7
5
  ## Usage
8
6
 
9
- TODO: Write usage instructions here
7
+ Colin's main focus is to parse command line arguments, but it's not constrained by it.
8
+
9
+ You can parse any array and get an options hash back.
10
+
11
+ To parse an array, just pass it as the only argument to `Colin::Parser#new`.
12
+
13
+ Let's see an example:
14
+
15
+ ```ruby
16
+ require "colin"
17
+
18
+ args = %w[first --name=Federico --age 100 second -y 2015 -f -nnumber]
19
+
20
+ cli = Colin::Parser.new(args)
21
+
22
+ cli.options
23
+ # => {:name=>"Federico", :age=>100, :y=>2015, :f=>true, :n=>"number"}
24
+
25
+ cli.args
26
+ # => ["first", "second"]
27
+ ```
28
+
29
+ If you want to assign names to the remaining arguments, you can call the `#named_options` method.
30
+
31
+ 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.
32
+
33
+ ```ruby
34
+ require "colin"
35
+
36
+ args = %w[first --name=Federico --age 100 second -y 2015 -f -nnumber third]
37
+
38
+ cli = Colin::Parser.new(args).named_options([:do, :dont])
39
+
40
+ cli.options
41
+ # => {:name=>"Federico",
42
+ # :age=>100,
43
+ # :y=>2015,
44
+ # :f=>true,
45
+ # :n=>"number",
46
+ # :do=>"first",
47
+ # :dont=>"second"}
48
+
49
+ cli.args
50
+ # => ["third"]
51
+ ```
10
52
 
11
53
  ## Installation
12
54
 
data/colin.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "colin"
7
- spec.version = "0.1.2"
7
+ spec.version = "0.1.3"
8
8
  spec.authors = ["Federico Iachetti"]
9
9
  spec.email = ["iachetti.federico@gmail.com"]
10
10
  spec.summary = %q{COmmand Line INterface.}
data/lib/colin.rb CHANGED
@@ -28,6 +28,7 @@ module Colin
28
28
  break if @skipped.empty?
29
29
  set(opt.to_s, @skipped.shift)
30
30
  end
31
+ self
31
32
  end
32
33
 
33
34
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Federico Iachetti