commander 4.2.1 → 4.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/.rubocop.yml +10 -0
- data/.rubocop_todo.yml +212 -0
- data/.travis.yml +0 -2
- data/Gemfile +1 -1
- data/History.rdoc +6 -0
- data/README.md +9 -4
- data/Rakefile +7 -4
- data/bin/commander +12 -12
- data/commander.gemspec +17 -18
- data/lib/commander/blank.rb +2 -2
- data/lib/commander/command.rb +63 -65
- data/lib/commander/configure.rb +1 -2
- data/lib/commander/core_ext.rb +1 -1
- data/lib/commander/core_ext/array.rb +2 -3
- data/lib/commander/core_ext/object.rb +1 -3
- data/lib/commander/delegates.rb +15 -4
- data/lib/commander/help_formatters.rb +2 -1
- data/lib/commander/help_formatters/base.rb +14 -7
- data/lib/commander/help_formatters/terminal.rb +5 -5
- data/lib/commander/help_formatters/terminal_compact.rb +2 -2
- data/lib/commander/methods.rb +0 -1
- data/lib/commander/runner.rb +1 -1
- data/lib/commander/user_interaction.rb +87 -91
- data/lib/commander/version.rb +1 -1
- data/spec/command_spec.rb +57 -58
- data/spec/configure_spec.rb +4 -4
- data/spec/core_ext/array_spec.rb +5 -7
- data/spec/core_ext/object_spec.rb +6 -8
- data/spec/help_formatters/terminal_spec.rb +19 -20
- data/spec/runner_spec.rb +179 -181
- data/spec/spec_helper.rb +12 -12
- data/spec/ui_spec.rb +10 -11
- metadata +23 -6
data/spec/spec_helper.rb
CHANGED
@@ -2,11 +2,11 @@ require 'rubygems'
|
|
2
2
|
require 'stringio'
|
3
3
|
require 'simplecov'
|
4
4
|
SimpleCov.start do
|
5
|
-
add_filter
|
5
|
+
add_filter '/spec/'
|
6
6
|
end
|
7
7
|
|
8
8
|
# Unshift so that local files load instead of something in gems
|
9
|
-
|
9
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
10
10
|
|
11
11
|
# This basically replicates the behavior of `require 'commander/import'`
|
12
12
|
# but without adding an `at_exit` hook, which interferes with exit code
|
@@ -25,13 +25,13 @@ end
|
|
25
25
|
|
26
26
|
def create_test_command
|
27
27
|
command :test do |c|
|
28
|
-
c.syntax =
|
29
|
-
c.description =
|
30
|
-
c.example
|
31
|
-
c.example
|
32
|
-
c.option '-v',
|
33
|
-
c.when_called do |args,
|
34
|
-
|
28
|
+
c.syntax = 'test [options] <file>'
|
29
|
+
c.description = 'test description'
|
30
|
+
c.example 'description', 'command'
|
31
|
+
c.example 'description 2', 'command 2'
|
32
|
+
c.option '-v', '--verbose', 'verbose description'
|
33
|
+
c.when_called do |args, _options|
|
34
|
+
'test %s' % args.join
|
35
35
|
end
|
36
36
|
end
|
37
37
|
@command = command :test
|
@@ -39,7 +39,7 @@ end
|
|
39
39
|
|
40
40
|
# Create a new command runner
|
41
41
|
|
42
|
-
def new_command_runner
|
42
|
+
def new_command_runner(*args, &block)
|
43
43
|
Commander::Runner.instance_variable_set :"@singleton", Commander::Runner.new(args)
|
44
44
|
program :name, 'test'
|
45
45
|
program :version, '1.2.3'
|
@@ -55,10 +55,10 @@ def command_runner
|
|
55
55
|
Commander::Runner.instance
|
56
56
|
end
|
57
57
|
|
58
|
-
def run
|
58
|
+
def run(*args)
|
59
59
|
new_command_runner(*args) do
|
60
60
|
program :help_formatter, Commander::HelpFormatter::Base
|
61
|
-
end.run!
|
61
|
+
end.run!
|
62
62
|
@output.string
|
63
63
|
end
|
64
64
|
|
data/spec/ui_spec.rb
CHANGED
@@ -2,30 +2,29 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Commander::UI do
|
4
4
|
include Commander::Methods
|
5
|
-
|
6
|
-
describe
|
7
|
-
it
|
8
|
-
result = Commander::UI.replace_tokens 'Welcome :name, enjoy your :object'.freeze, :
|
5
|
+
|
6
|
+
describe '.replace_tokens' do
|
7
|
+
it 'should replace tokens within a string, with hash values' do
|
8
|
+
result = Commander::UI.replace_tokens 'Welcome :name, enjoy your :object'.freeze, name: 'TJ', object: 'cookie'
|
9
9
|
expect(result).to eq('Welcome TJ, enjoy your cookie')
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
describe
|
14
|
-
it
|
13
|
+
describe 'progress' do
|
14
|
+
it 'should not die on an empty list' do
|
15
15
|
exception = false
|
16
16
|
begin
|
17
17
|
progress([]) {}
|
18
18
|
rescue
|
19
19
|
exception = true
|
20
20
|
end
|
21
|
-
expect(exception).not_to
|
21
|
+
expect(exception).not_to be true
|
22
22
|
end
|
23
23
|
end
|
24
|
-
|
25
|
-
describe
|
26
|
-
it
|
24
|
+
|
25
|
+
describe '.available_editor' do
|
26
|
+
it 'should not fail on available editors with shell arguments' do
|
27
27
|
expect(Commander::UI.available_editor('sh -c')).to eq('sh -c')
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
31
30
|
end
|
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
|
+
version: 4.3.0
|
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: 2015-02-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: highline
|
@@ -67,17 +67,34 @@ dependencies:
|
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rubocop
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.29.0
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 0.29.0
|
70
84
|
description: The complete solution for Ruby command-line executables. Commander bridges
|
71
85
|
the gap between other terminal related libraries you know and love (OptionParser,
|
72
86
|
HighLine), while providing many new features, and an elegant API.
|
73
87
|
email:
|
74
|
-
-
|
88
|
+
- gabriel@gabrielgilder.com
|
75
89
|
executables:
|
76
90
|
- commander
|
77
91
|
extensions: []
|
78
92
|
extra_rdoc_files: []
|
79
93
|
files:
|
80
94
|
- ".gitignore"
|
95
|
+
- ".rspec"
|
96
|
+
- ".rubocop.yml"
|
97
|
+
- ".rubocop_todo.yml"
|
81
98
|
- ".travis.yml"
|
82
99
|
- DEVELOPMENT
|
83
100
|
- Gemfile
|
@@ -119,7 +136,7 @@ files:
|
|
119
136
|
- spec/runner_spec.rb
|
120
137
|
- spec/spec_helper.rb
|
121
138
|
- spec/ui_spec.rb
|
122
|
-
homepage:
|
139
|
+
homepage: https://github.com/tj/commander
|
123
140
|
licenses:
|
124
141
|
- MIT
|
125
142
|
metadata: {}
|
@@ -138,8 +155,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
155
|
- !ruby/object:Gem::Version
|
139
156
|
version: '0'
|
140
157
|
requirements: []
|
141
|
-
rubyforge_project:
|
142
|
-
rubygems_version: 2.
|
158
|
+
rubyforge_project:
|
159
|
+
rubygems_version: 2.4.3
|
143
160
|
signing_key:
|
144
161
|
specification_version: 4
|
145
162
|
summary: The complete solution for Ruby command-line executables
|