slop 3.5.0 → 3.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3fa9956c84ddd760c06fd3ace9d4e0b76a7fea5b
4
- data.tar.gz: 38bc53ca3626ec471672ec15022392e6e32cb26d
3
+ metadata.gz: 95327fe15a3e8091259a7a045f9ede744256ae52
4
+ data.tar.gz: 6804548aa33795082ef1068a7c3021e3305258c5
5
5
  SHA512:
6
- metadata.gz: b9acff23d30d56234cb7744f1eefb16328987d198a340ead9e7e793dab38e33e55b33c3250a302eea0b138abe9a2da848e044e963c23abf42387324fdbc5597e
7
- data.tar.gz: d9c073d8f01c14d4c8f40cd0211eeb2f88863e82a1d8c97ab66c3ccf7f75a55cc519032f69d3589c2a6ef33951c87d304ad7e7b62b6da37cc4944a51731220ad
6
+ metadata.gz: c625631bde9b8289e1f50337de14139a762f12b873b2f94b7a1d406a3605202269dbef1ee19c8a3978379415afb902528ccc438f76fe3d563deb0a0f180f3413
7
+ data.tar.gz: b8de8a12ee0aca903b74950009d10c4f66b437430c9983eb2ba61ef2ac988ce686cff56428f1caf0f3c2098d076ad9a3d4da5d901ce9768a2df5aae7b8870af7
@@ -1,11 +1,8 @@
1
1
  rvm:
2
- - 1.8.7
3
- - 1.9.2
4
2
  - 1.9.3
3
+ - 2.1
5
4
  - ruby-head
6
- - jruby-18mode
7
5
  - jruby-19mode
8
- - rbx-18mode
9
6
  notifications:
10
7
  email:
11
8
  on_success: change
data/CHANGES.md CHANGED
@@ -1,3 +1,9 @@
1
+ 3.6.0 (2014-06-18)
2
+ ------------------
3
+
4
+ * Add example of rest arguments usage in the readme file #139
5
+ * Default values on options are printed in the help message #134
6
+
1
7
  3.5.0 (2014-03-12)
2
8
  ------------------
3
9
 
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
- * `strict` - Enable strict mode. When processing unknown options, Slop will
45
- raise an `InvalidOptionError`. **default:** *false*.
46
- * `help` - Automatically add the `--help` option. **default:** *false*.
47
- * `banner` - Set the help banner text. **default:** *nil*.
48
- * `ignore_case` - When enabled, `-A` will look for the `-a` option if `-A`
49
- does not exist. **default:** *false*.
50
- * `autocreate` - Autocreate options on the fly. **default:** *false*.
51
- * `arguments` - Force all options to expect arguments. **default:** *false*.
52
- * `optional_arguments` - Force all options to accept optional arguments.
53
- **default:** *false*.
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
 
@@ -4,7 +4,7 @@ require 'slop/commands'
4
4
  class Slop
5
5
  include Enumerable
6
6
 
7
- VERSION = '3.5.0'
7
+ VERSION = '3.6.0'
8
8
 
9
9
  # The main Error class, all Exception classes inherit from this class.
10
10
  class Error < StandardError; end
@@ -138,7 +138,12 @@ class Slop
138
138
  out << (' ' * (@slop.config[:longest_flag] + 8))
139
139
  end
140
140
 
141
- "#{out}#{description}"
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
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'slop'
3
- s.version = '3.5.0'
3
+ s.version = '3.6.0'
4
4
  s.summary = 'Simple Lightweight Option Parsing'
5
5
  s.description = 'A simple DSL for gathering options and parsing the command line'
6
6
  s.author = 'Lee Jarvis'
@@ -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.5.0
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-03-12 00:00:00.000000000 Z
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
- - ".gitignore"
48
- - ".travis.yml"
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.2.0
82
+ rubygems_version: 2.0.14
83
83
  signing_key:
84
84
  specification_version: 4
85
85
  summary: Simple Lightweight Option Parsing