commander 4.4.3 → 4.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +9 -2
- data/.rubocop_todo.yml +1 -1
- data/.travis.yml +5 -3
- data/History.rdoc +4 -0
- data/README.md +17 -2
- data/commander.gemspec +2 -1
- data/lib/commander/user_interaction.rb +35 -12
- data/lib/commander/version.rb +1 -1
- data/spec/methods_spec.rb +43 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 44969cb91e63472555ff36e2d39513cb5ac4c0f8f9c626f8b85bcd836e1a8227
|
4
|
+
data.tar.gz: '00957023e0b9d380efab260b267082dd15c11c8a7f5e9b536f65bd8a0719b370'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c71a8f9f030be8c93267a75027cfeac2712d31cc8907bfcfc1534f190d3f4615a930e13fbc0f1cb7cbbd7eae73cffa6136b2d63657193639064a4fde6d95f7c
|
7
|
+
data.tar.gz: 12e7152d828da458b7ca79a10ce08d8a8ef00d815feaf86a394b68da8892b64ce8422df0530a6c470a2784fcd23ae561abefbeb33e6e7ddddd47ea64c0cd4545
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
inherit_from: .rubocop_todo.yml
|
2
2
|
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 1.9
|
5
|
+
|
6
|
+
# not Ruby 1.9.3 compatible
|
7
|
+
Style/PercentLiteralDelimiters:
|
8
|
+
Enabled: false
|
9
|
+
|
3
10
|
# Offense count: 5
|
4
11
|
Encoding:
|
5
12
|
Enabled: false
|
@@ -23,10 +30,10 @@ Style/NumericLiteralPrefix:
|
|
23
30
|
Style/MethodMissing:
|
24
31
|
Enabled: false
|
25
32
|
|
26
|
-
|
33
|
+
Layout/SpaceInsideStringInterpolation:
|
27
34
|
Enabled: false
|
28
35
|
|
29
|
-
|
36
|
+
Layout/MultilineOperationIndentation:
|
30
37
|
Enabled: false
|
31
38
|
|
32
39
|
Style/EmptyMethod:
|
data/.rubocop_todo.yml
CHANGED
data/.travis.yml
CHANGED
data/History.rdoc
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
[<img src="https://
|
2
|
-
[![Inline docs](http://inch-ci.org/github/commander-rb/commander.
|
1
|
+
[<img src="https://api.travis-ci.org/commander-rb/commander.svg" alt="Build Status" />](http://travis-ci.org/commander-rb/commander)
|
2
|
+
[![Inline docs](http://inch-ci.org/github/commander-rb/commander.svg)](http://inch-ci.org/github/commander-rb/commander)
|
3
3
|
|
4
4
|
# Commander
|
5
5
|
|
@@ -339,6 +339,21 @@ $ foo install gem
|
|
339
339
|
# => installing to
|
340
340
|
```
|
341
341
|
|
342
|
+
### Long descriptions
|
343
|
+
|
344
|
+
If you need to have a long command description, keep your short description under `summary`, and consider multi-line strings for `description`:
|
345
|
+
|
346
|
+
```ruby
|
347
|
+
program :summary, 'Stupid command that prints foo or bar.'
|
348
|
+
program :description, %q(
|
349
|
+
#{c.summary}
|
350
|
+
|
351
|
+
More information about that stupid command that prints foo or bar.
|
352
|
+
|
353
|
+
And more
|
354
|
+
)
|
355
|
+
```
|
356
|
+
|
342
357
|
### Additional Global Help
|
343
358
|
|
344
359
|
Arbitrary help can be added using the following `#program` symbol:
|
data/commander.gemspec
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
|
2
3
|
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
3
4
|
require 'commander/version'
|
4
5
|
|
@@ -26,6 +27,6 @@ Gem::Specification.new do |s|
|
|
26
27
|
s.add_development_dependency('rubocop', '~> 0.41.1')
|
27
28
|
s.add_development_dependency('json', '< 2.0')
|
28
29
|
else
|
29
|
-
s.add_development_dependency('rubocop', '~> 0.
|
30
|
+
s.add_development_dependency('rubocop', '~> 0.49.1')
|
30
31
|
end
|
31
32
|
end
|
@@ -324,22 +324,45 @@ module Commander
|
|
324
324
|
# Implements ask_for_CLASS methods.
|
325
325
|
|
326
326
|
module AskForClass
|
327
|
-
DEPRECATED_CONSTANTS = [:Config, :TimeoutError, :MissingSourceFile, :NIL, :TRUE, :FALSE, :Fixnum, :Bignum].freeze
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
# All Classes that respond to #parse
|
332
|
-
# Ignore constants that trigger deprecation warnings
|
333
|
-
(Object.constants - DEPRECATED_CONSTANTS).map do |const|
|
334
|
-
Object.const_get(const)
|
335
|
-
end.select do |const|
|
336
|
-
const.class == Class && const.respond_to?(:parse)
|
337
|
-
end
|
338
|
-
).each do |klass|
|
327
|
+
DEPRECATED_CONSTANTS = [:Config, :TimeoutError, :MissingSourceFile, :NIL, :TRUE, :FALSE, :Fixnum, :Bignum, :Data].freeze
|
328
|
+
|
329
|
+
# define methods for common classes
|
330
|
+
[Float, Integer, String, Symbol, Regexp, Array, File, Pathname].each do |klass|
|
339
331
|
define_method "ask_for_#{klass.to_s.downcase}" do |prompt|
|
340
332
|
$terminal.ask(prompt, klass)
|
341
333
|
end
|
342
334
|
end
|
335
|
+
|
336
|
+
def method_missing(method_name, *arguments, &block)
|
337
|
+
if method_name.to_s =~ /^ask_for_(.*)/
|
338
|
+
if arguments.count != 1
|
339
|
+
fail ArgumentError, "wrong number of arguments (given #{arguments.count}, expected 1)"
|
340
|
+
end
|
341
|
+
prompt = arguments.first
|
342
|
+
requested_class = Regexp.last_match[1]
|
343
|
+
|
344
|
+
# All Classes that respond to #parse
|
345
|
+
# Ignore constants that trigger deprecation warnings
|
346
|
+
available_classes = (Object.constants - DEPRECATED_CONSTANTS).map do |const|
|
347
|
+
Object.const_get(const)
|
348
|
+
end.select do |const|
|
349
|
+
const.class == Class && const.respond_to?(:parse)
|
350
|
+
end
|
351
|
+
|
352
|
+
klass = available_classes.find { |k| k.to_s.downcase == requested_class }
|
353
|
+
if klass
|
354
|
+
$terminal.ask(prompt, klass)
|
355
|
+
else
|
356
|
+
super
|
357
|
+
end
|
358
|
+
else
|
359
|
+
super
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
def respond_to_missing?(method_name, include_private = false)
|
364
|
+
method_name.to_s.start_with?('ask_for_') || super
|
365
|
+
end
|
343
366
|
end
|
344
367
|
|
345
368
|
##
|
data/lib/commander/version.rb
CHANGED
data/spec/methods_spec.rb
CHANGED
@@ -6,8 +6,49 @@ describe Commander::Methods do
|
|
6
6
|
expect(subject.ancestors).to include(Commander::UI)
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
describe 'AskForClass' do
|
10
|
+
it 'includes Commander::UI::AskForClass' do
|
11
|
+
expect(subject.ancestors).to include(Commander::UI::AskForClass)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'defining methods' do
|
15
|
+
let(:terminal) { double }
|
16
|
+
|
17
|
+
before do
|
18
|
+
allow(terminal).to receive(:ask)
|
19
|
+
$_old_terminal = $terminal
|
20
|
+
$terminal = terminal
|
21
|
+
end
|
22
|
+
|
23
|
+
after do
|
24
|
+
$terminal = $_old_terminal
|
25
|
+
end
|
26
|
+
|
27
|
+
subject do
|
28
|
+
Class.new do
|
29
|
+
include Commander::UI::AskForClass
|
30
|
+
end.new
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'defines common "ask_for_*" methods' do
|
34
|
+
expect(subject.respond_to?(:ask_for_float)).to be_truthy
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'responds to "ask_for_*" methods for classes that implement #parse' do
|
38
|
+
expect(subject.respond_to?(:ask_for_datetime)).to be_truthy
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'fails "ask_for_*" method invocations without a prompt' do
|
42
|
+
expect do
|
43
|
+
subject.ask_for_datetime
|
44
|
+
end.to raise_error(ArgumentError)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'implements "ask_for_*"' do
|
48
|
+
expect(terminal).to receive(:ask)
|
49
|
+
subject.ask_for_datetime('hi')
|
50
|
+
end
|
51
|
+
end
|
11
52
|
end
|
12
53
|
|
13
54
|
it 'includes Commander::Delegates' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: commander
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.4.
|
4
|
+
version: 4.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TJ Holowaychuk
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-01-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: highline
|
@@ -73,14 +73,14 @@ dependencies:
|
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
76
|
+
version: 0.49.1
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version:
|
83
|
+
version: 0.49.1
|
84
84
|
description: The complete solution for Ruby command-line executables. Commander bridges
|
85
85
|
the gap between other terminal related libraries you know and love (OptionParser,
|
86
86
|
HighLine), while providing many new features, and an elegant API.
|
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
157
|
version: '0'
|
158
158
|
requirements: []
|
159
159
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.
|
160
|
+
rubygems_version: 2.7.4
|
161
161
|
signing_key:
|
162
162
|
specification_version: 4
|
163
163
|
summary: The complete solution for Ruby command-line executables
|