argparser 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +4 -0
- data/HISTORY.md +5 -0
- data/README.md +11 -12
- data/Rakefile +1 -1
- data/argparser.gemspec +0 -1
- data/lib/argparser/version.rb +1 -1
- metadata +1 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9c717835823cf29218ab1893f167714943d00ec
|
4
|
+
data.tar.gz: c12e9a7624dc121e0ce1fcf0d708eaa875300fd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21606aa348b874c05a4ac882e5c0f78ba7f60634bcd7b275fb4367a125e10a8dd933cc7c18a335e6ea19c82128c37c059ae22e0e8c7bc4ad317e2c1b02b09cc0
|
7
|
+
data.tar.gz: 8be8cce50bd10f549916e33d78b0075a2a23a94db83cf63ff9c048be37da3f1134962c5fd82c578547ca93d1392a2920ceccb24a0321500a78193c13d77e6676
|
data/Gemfile
CHANGED
data/HISTORY.md
CHANGED
data/README.md
CHANGED
@@ -14,29 +14,28 @@ args= ArgParser.new( # Here goes the manifest.
|
|
14
14
|
:program => 'example.rb', # Use additional properties like these:
|
15
15
|
:version => '1.0', # :info, :copyright, :license,
|
16
16
|
:options => [{ # :package, :bugs, :homepage
|
17
|
-
:names => %w[m
|
18
|
-
:
|
17
|
+
:names => %w[mode m],
|
18
|
+
:param => 'first|second|third',
|
19
19
|
:default => 'first',
|
20
20
|
:multiple => true,
|
21
21
|
:help => 'Example mode.',
|
22
22
|
:validate => (lambda {|this, parser| # Validating value in-line
|
23
23
|
possible = this.argument.split('|')
|
24
24
|
this.value.select{|v| possible.include?(v)}.size == this.value.size })
|
25
|
-
},
|
26
|
-
|
27
|
-
:
|
25
|
+
}],
|
26
|
+
:arguments => [{
|
27
|
+
:name => 'file',
|
28
28
|
:required => true,
|
29
29
|
:help => 'Filename or - for stdin.',
|
30
30
|
:validate => (lambda {|this, parser|
|
31
31
|
if this.value == '-'
|
32
|
-
this.
|
32
|
+
this.reset.set_value($stdin.read)
|
33
33
|
else
|
34
34
|
parser.terminate(2, 'No such file') unless File.exists?(this.value)
|
35
|
-
this.
|
36
|
-
end
|
37
|
-
true })
|
35
|
+
this.reset.set_value(File.read(this.value))
|
36
|
+
end })
|
38
37
|
}]
|
39
|
-
).parse
|
38
|
+
).parse # Uses ARGV by default, you may supply your own arguments.
|
40
39
|
# It exits if bad arguments given or they aren't validated.
|
41
40
|
|
42
41
|
puts args['mode'].value.inspect # So we could use our options...
|
@@ -58,7 +57,6 @@ Expected argument: file
|
|
58
57
|
example.rb [-m, --mode first|second|third]... file
|
59
58
|
[-m, --mode first|second|third]...
|
60
59
|
Example mode.
|
61
|
-
Defaults to: first
|
62
60
|
[--help]
|
63
61
|
Print this help and exit.
|
64
62
|
[--version]
|
@@ -88,8 +86,9 @@ Unknown option: a
|
|
88
86
|
## Consider more rules
|
89
87
|
* `--help` and `--version` options provided unless specified explicitly
|
90
88
|
* printed synopsis provided unless specified explicitly
|
91
|
-
* `:default` setting assigns default option's value if value isn't specified
|
89
|
+
* `:default` setting assigns default option's value if value isn't specified
|
92
90
|
* `--` argument honored
|
91
|
+
* `ArgParser#parse` supports block(option_name, option_value) to read options/arguments supplied
|
93
92
|
|
94
93
|
## Tests
|
95
94
|
`bundle exec rake test`
|
data/Rakefile
CHANGED
data/argparser.gemspec
CHANGED
data/lib/argparser/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: argparser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sinm
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '4.7'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rubocop
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0.30'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0.30'
|
69
55
|
description: "== Yet another ruby command line argument parser library"
|
70
56
|
email: sinm.sinm@gmail.com
|
71
57
|
executables: []
|