colin 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +47 -5
- data/colin.gemspec +1 -1
- data/lib/colin.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0140f7ae2032f04b7c20e60bec743b521c472b03
|
4
|
+
data.tar.gz: fa9a91123f70ba5d72fee59c5017ad9728599e67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7745ec915493d1c79f18ecf5c2be9329e24591a1eede5aa54887e18c2cb6935f71a70fd80dc20169418cc5fd4e3d566119552a20d84b4b81aacf97b913539828
|
7
|
+
data.tar.gz: 9c9c305b73c88929b825601279c370651fc4c49a82503812270dfc0e2a7f1fb9b4ac990bf5964a60222851c3b82c60dcae85c6f453d026b9b397a92247ac3f3d
|
data/README.md
CHANGED
@@ -1,12 +1,54 @@
|
|
1
|
-
#
|
1
|
+
# CoLIn
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
Nothing to see here yet
|
3
|
+
**Co**mmand **L**ine **In**terface.
|
6
4
|
|
7
5
|
## Usage
|
8
6
|
|
9
|
-
|
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.
|
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