slop 3.5.0 → 3.6.0
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/.travis.yml +1 -4
- data/CHANGES.md +6 -0
- data/README.md +34 -14
- data/lib/slop.rb +1 -1
- data/lib/slop/option.rb +6 -1
- data/slop.gemspec +1 -1
- data/test/option_test.rb +7 -0
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95327fe15a3e8091259a7a045f9ede744256ae52
|
4
|
+
data.tar.gz: 6804548aa33795082ef1068a7c3021e3305258c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c625631bde9b8289e1f50337de14139a762f12b873b2f94b7a1d406a3605202269dbef1ee19c8a3978379415afb902528ccc438f76fe3d563deb0a0f180f3413
|
7
|
+
data.tar.gz: b8de8a12ee0aca903b74950009d10c4f66b437430c9983eb2ba61ef2ac988ce686cff56428f1caf0f3c2098d076ad9a3d4da5d901ce9768a2df5aae7b8870af7
|
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
data/README.md
CHANGED
@@ -41,20 +41,16 @@ Configuration Options
|
|
41
41
|
|
42
42
|
All of these options can be sent to `Slop.new` or `Slop.parse` in Hash form.
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
* `multiple_switches` - When disabled, Slop will parse `-abc` as the option `a`
|
55
|
-
with the argument `bc` rather than 3 separate options. **default:** *true*.
|
56
|
-
* `longest_flag` - The longest string flag, used to aid configuring help
|
57
|
-
text. **default:** *0*.
|
44
|
+
| Option | Description | Default/Example |
|
45
|
+
| ------ | ----------- | --------------- |
|
46
|
+
| strict | Enable strict mode. Slop will raise an `InvalidOptionError` for unkown options. | `false` |
|
47
|
+
| help | Automatically add the `--help` option. | `false` |
|
48
|
+
| banner | Set the help banner text. | `nil` |
|
49
|
+
| ignore_case | When enabled, `-A` will look for the `-a` option if `-A` does not exist. | `false` |
|
50
|
+
| autocreate | Autocreate options on the fly. | `false` |
|
51
|
+
| arguments | Force all options to expect arguments. | `false` |
|
52
|
+
| optional_arguments | Force all options to accept optional arguments. | `false` |
|
53
|
+
| multiple_switches | When disabled, Slop will parse `-abc` as the option `a` with the argument `bc` rather than 3 separate options. | `true` |
|
58
54
|
|
59
55
|
Lists
|
60
56
|
-----
|
@@ -139,6 +135,30 @@ opts.to_hash(true) # Pass true to tell Slop to merge sub-command option values.
|
|
139
135
|
# => { :v => nil, :add => { :v => true, :name => "Lee" } }
|
140
136
|
```
|
141
137
|
|
138
|
+
Remaining arguments
|
139
|
+
-------------------
|
140
|
+
|
141
|
+
The *parse!* method will remove any options and option arguments from the original Array:
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
# restarguments.rb
|
145
|
+
opts = Slop.parse! do
|
146
|
+
on :foo
|
147
|
+
end
|
148
|
+
```
|
149
|
+
|
150
|
+
Example:
|
151
|
+
|
152
|
+
```
|
153
|
+
ruby restarguments.rb --foo bar
|
154
|
+
```
|
155
|
+
|
156
|
+
```
|
157
|
+
opts.to_hash = { :foo => true }
|
158
|
+
|
159
|
+
ARGV #=> ["bar"]
|
160
|
+
```
|
161
|
+
|
142
162
|
Woah woah, why you hating on OptionParser?
|
143
163
|
------------------------------------------
|
144
164
|
|
data/lib/slop.rb
CHANGED
data/lib/slop/option.rb
CHANGED
@@ -138,7 +138,12 @@ class Slop
|
|
138
138
|
out << (' ' * (@slop.config[:longest_flag] + 8))
|
139
139
|
end
|
140
140
|
|
141
|
-
|
141
|
+
if config[:default]
|
142
|
+
default = config[:default]
|
143
|
+
"#{out}#{description} (default: #{default})"
|
144
|
+
else
|
145
|
+
"#{out}#{description}"
|
146
|
+
end
|
142
147
|
end
|
143
148
|
alias help to_s
|
144
149
|
|
data/slop.gemspec
CHANGED
data/test/option_test.rb
CHANGED
@@ -130,6 +130,13 @@ class OptionTest < TestCase
|
|
130
130
|
assert_equal " -V, Display the version", slop.fetch_option(:V).help
|
131
131
|
end
|
132
132
|
|
133
|
+
test "printing options that have defaults" do
|
134
|
+
opts = Slop.new
|
135
|
+
opts.on :n, :name=, 'Your name', :default => 'Lee'
|
136
|
+
|
137
|
+
assert_equal " -n, --name Your name (default: Lee)", opts.fetch_option(:name).to_s
|
138
|
+
end
|
139
|
+
|
133
140
|
test "overwriting the help text" do
|
134
141
|
slop = Slop.new
|
135
142
|
slop.on :foo, :help => ' -f, --foo SOMETHING FOOEY'
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Jarvis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 5.0.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 5.0.0
|
41
41
|
description: A simple DSL for gathering options and parsing the command line
|
@@ -44,8 +44,8 @@ executables: []
|
|
44
44
|
extensions: []
|
45
45
|
extra_rdoc_files: []
|
46
46
|
files:
|
47
|
-
-
|
48
|
-
-
|
47
|
+
- .gitignore
|
48
|
+
- .travis.yml
|
49
49
|
- CHANGES.md
|
50
50
|
- Gemfile
|
51
51
|
- LICENSE
|
@@ -69,17 +69,17 @@ require_paths:
|
|
69
69
|
- lib
|
70
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- -
|
72
|
+
- - '>='
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: 1.8.7
|
75
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
76
|
requirements:
|
77
|
-
- -
|
77
|
+
- - '>='
|
78
78
|
- !ruby/object:Gem::Version
|
79
79
|
version: '0'
|
80
80
|
requirements: []
|
81
81
|
rubyforge_project:
|
82
|
-
rubygems_version: 2.
|
82
|
+
rubygems_version: 2.0.14
|
83
83
|
signing_key:
|
84
84
|
specification_version: 4
|
85
85
|
summary: Simple Lightweight Option Parsing
|