pargser 0.1.0 → 0.1.1

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 +2 -2
  3. data/lib/pargser.rb +24 -21
  4. data/pargser.gemspec +1 -1
  5. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e3dffd531e9a47357559aa2315aaf5f3151b52e9
4
- data.tar.gz: 5c9236c175de9fcb1af91409cd53c77720f0fcfe
3
+ metadata.gz: 2766da1ace1d84c0bdd1f2095e32c7aa4ef0cdee
4
+ data.tar.gz: ab46a7f67e9ad2d730d13d51bdaa3acf5d91ff64
5
5
  SHA512:
6
- metadata.gz: fa192889e980aef25e0691b026879ac977d69d25ad1b843d37a04876338ce372fcfda7abaa1e0ef9c6c6e9a3981beb88c51865910b49f486b0f60294f040bfd4
7
- data.tar.gz: a75e25d2a6d8d370cbaae90e107b4cb512bda23dd2cbe03af0097484975553c473d5540b41ce18bb4ccf802830f0cfaabab985bfc069a89f49a4f08a5dd55667
6
+ metadata.gz: 6772dad90c716c614436b60a047ba2db174d309a4842592da2a46d4cb17e6dc023e8ccce9818a501cc7d7a8300e96cff0c37f0ada244f1631df73091508d9a2e
7
+ data.tar.gz: ee2a5d230a2f81d6053a55c1cc6e6498d01d3c9f0c823cb1b0f8cbb27ae62b7a65ddf15b356cd779ab9e829939095bafa31d16ede7f101019e00a70888b052a1
data/README.md CHANGED
@@ -21,7 +21,7 @@ Or install it yourself as:
21
21
 
22
22
  ## Usage
23
23
 
24
- Very straightforward
24
+ Rather straightforward
25
25
 
26
26
  p = Pargser.new.key('-f', '--fantastic') {
27
27
  @fantastic = true
@@ -68,7 +68,7 @@ Very straightforward
68
68
 
69
69
  p.keys_doc.should == expected_docs
70
70
 
71
- For details please consult documentation:
71
+ For details please consult documentation: http://www.rubydoc.info/gems/pargser
72
72
 
73
73
  ## Contributing
74
74
 
data/lib/pargser.rb CHANGED
@@ -2,12 +2,14 @@ require "pargser"
2
2
 
3
3
  # The Ruby-Style (e,g, nice and laconic) command line parser that easily supports:
4
4
  #
5
- # --keys
6
- # optional keys with any number of aliases aliases
7
- # -name value
8
- # key that wants value (next agrument), optionally with default value
9
- # --
10
- # no more keys past double dash
5
+ # * --keys
6
+ # optional keys with any number of aliases aliases
7
+ #
8
+ # * -name value
9
+ # key that wants value (next agrument), optionally with default value
10
+ #
11
+ # * --
12
+ # no more keys past double dash
11
13
  #
12
14
  # and regular (all other) arguments.
13
15
  #
@@ -15,7 +17,7 @@ require "pargser"
15
17
  #
16
18
  class Pargser
17
19
 
18
- VERSION = "0.1.0"
20
+ VERSION = "0.1.1"
19
21
 
20
22
  # The pargser errors, e.g. wrong usage or command line does not fit specified
21
23
  # keys ocnstraints.
@@ -25,7 +27,8 @@ class Pargser
25
27
  # Create parser instance with a list of arguments. Otherwise, arguments can
26
28
  # be passed to #parse call.
27
29
  #
28
- # @param [Array] args arguments
30
+ # @param args [Array] optional command line arguments. Usually it is more convenient
31
+ # to pass them to #parse
29
32
  def initialize args=[]
30
33
  @args = args
31
34
  @keys = {}
@@ -33,23 +36,23 @@ class Pargser
33
36
  @docs = []
34
37
  end
35
38
 
36
- # Register key handler.
37
- # When #parse handler blocks will be called in order of appearance in
38
- # arguments array
39
+ # Register a new key handler. When #parse fonds a key (or an alias) the blocks will be called.
40
+ # Invocation order is same as in the command line.
39
41
  #
42
+ # @param name [String] key name
40
43
  #
41
- # @param [String] name key name
44
+ # @param aliases [Array(String)] any number of aliases for the key
42
45
  #
43
- # @param [Array(String)] aliases for the key
44
- #
45
- # @param [Boolean] :needs_value if set then the parser wants a value argument after the
46
+ # @param needs_value [Boolean] if set then the parser wants a value argument after the
46
47
  # key which will be passed to block as an argument. if default param is not set and
47
48
  # the key will not be detected, Pargser::Error will be raised
48
49
  #
49
- # @param [String] :default value. if set, needs_value parameter can be omitted - the handler
50
- # block will be passed either with this value or with one specified in args.
50
+ # @param default [String] default value. if set, needs_value parameter can be omitted -
51
+ # the handler block will be invoked with either this value or with one from args.
52
+ #
53
+ # @param doc [String] optional documentation string that will be used in #keys_doc
51
54
  #
52
- # @param [String] :doc optional documentation string that will be used in #keys_doc
55
+ # @return [Pargser] self
53
56
  #
54
57
  # @yield block if the key is found with optional value argument
55
58
  #
@@ -88,10 +91,10 @@ class Pargser
88
91
  #
89
92
  # You can optionally set other arguments than specified in constructor
90
93
  #
91
- # @param [Array] args to parse. If specified, arguments passed to constructor
94
+ # @param args [Array(String)] to parse. If specified, arguments passed to constructor
92
95
  # will be ignored and lost
93
- # @return [Array] non-keys arguments (keys afer '--' or other arguments)
94
- # @yield [String] non keys argumenrs (same as returned)
96
+ # @return [Array] non-keys arguments (keys after '--' or other arguments)
97
+ # @yield [String] non keys arguments in order of appearance (same as returned)
95
98
  def parse args=nil
96
99
  @args = args.clone if args
97
100
  no_more_keys = false
data/pargser.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "pargser"
8
8
  spec.version = Pargser::VERSION
9
9
  spec.authors = ["sergeych"]
10
- spec.email = ["sergeych"]
10
+ spec.email = ["real.sergeych@gmail.com"]
11
11
  spec.summary = %q{Very Ruby-style command line parser}
12
12
  spec.description = %q{Allows to write CLI in ruby without headache of arguments parsing and
13
13
  usage writing}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pargser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - sergeych
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-08 00:00:00.000000000 Z
11
+ date: 2015-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -56,7 +56,7 @@ description: |-
56
56
  Allows to write CLI in ruby without headache of arguments parsing and
57
57
  usage writing
58
58
  email:
59
- - sergeych
59
+ - real.sergeych@gmail.com
60
60
  executables: []
61
61
  extensions: []
62
62
  extra_rdoc_files: []