commander 4.5.2 → 4.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +26 -6
- data/.rubocop_todo.yml +4 -4
- data/.travis.yml +1 -1
- data/Gemfile +2 -0
- data/History.rdoc +6 -0
- data/Rakefile +3 -1
- data/bin/commander +2 -1
- data/commander.gemspec +9 -13
- data/lib/commander.rb +2 -0
- data/lib/commander/blank.rb +2 -0
- data/lib/commander/command.rb +7 -4
- data/lib/commander/configure.rb +2 -0
- data/lib/commander/core_ext.rb +2 -0
- data/lib/commander/core_ext/array.rb +2 -0
- data/lib/commander/core_ext/object.rb +2 -0
- data/lib/commander/delegates.rb +3 -1
- data/lib/commander/help_formatters.rb +3 -1
- data/lib/commander/help_formatters/base.rb +2 -0
- data/lib/commander/help_formatters/terminal.rb +2 -0
- data/lib/commander/help_formatters/terminal_compact.rb +2 -0
- data/lib/commander/import.rb +2 -0
- data/lib/commander/methods.rb +2 -0
- data/lib/commander/platform.rb +2 -0
- data/lib/commander/runner.rb +22 -20
- data/lib/commander/user_interaction.rb +18 -12
- data/lib/commander/version.rb +3 -1
- data/spec/command_spec.rb +2 -0
- data/spec/configure_spec.rb +2 -0
- data/spec/core_ext/array_spec.rb +3 -1
- data/spec/core_ext/object_spec.rb +2 -0
- data/spec/help_formatters/terminal_compact_spec.rb +2 -0
- data/spec/help_formatters/terminal_spec.rb +2 -0
- data/spec/methods_spec.rb +2 -0
- data/spec/runner_spec.rb +18 -0
- data/spec/spec_helper.rb +4 -2
- data/spec/ui_spec.rb +4 -2
- metadata +28 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f91f8a37c32e7971823b150b8b89d7f992a6971c66351ae7527b27cdbf0926db
|
4
|
+
data.tar.gz: bcd3c3131f145cea800da48c7231a6d3b0b892eed9107fd64dac52b03da2f44b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9c808ed77df3bc880db7a790ca207b6b6beb98be447f27f55fdcd25dc32c1131bb06d6d69e47de076b590ff4182e250b6b752b3bf2439ef0f94a2168d3acc40
|
7
|
+
data.tar.gz: fcfb725ce863649b098cea94314d612a5b755abd996199ed63a3e8018baef804790b8ce57e02229fed75c3247597f2030aab3bec47d0a544eb81586c45548722
|
data/.rubocop.yml
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
inherit_from: .rubocop_todo.yml
|
2
2
|
|
3
3
|
AllCops:
|
4
|
-
TargetRubyVersion:
|
4
|
+
TargetRubyVersion: 2.4
|
5
|
+
NewCops: enable
|
6
|
+
SuggestExtensions: false
|
5
7
|
|
6
8
|
# not Ruby 1.9.3 compatible
|
7
9
|
Style/PercentLiteralDelimiters:
|
8
10
|
Enabled: false
|
9
11
|
|
10
|
-
#
|
11
|
-
|
12
|
-
|
12
|
+
# Enforce trailing comma after last item of multiline arrays.
|
13
|
+
Style/TrailingCommaInArrayLiteral:
|
14
|
+
EnforcedStyleForMultiline: comma
|
13
15
|
|
14
16
|
# Enforce trailing comma after last item of multiline hashes.
|
15
|
-
Style/
|
17
|
+
Style/TrailingCommaInHashLiteral:
|
16
18
|
EnforcedStyleForMultiline: comma
|
17
19
|
|
18
20
|
Metrics/BlockLength:
|
@@ -27,7 +29,7 @@ Style/ParallelAssignment:
|
|
27
29
|
Style/NumericLiteralPrefix:
|
28
30
|
EnforcedOctalStyle: zero_only
|
29
31
|
|
30
|
-
Style/
|
32
|
+
Style/MissingRespondToMissing:
|
31
33
|
Enabled: false
|
32
34
|
|
33
35
|
Layout/SpaceInsideStringInterpolation:
|
@@ -42,3 +44,21 @@ Style/EmptyMethod:
|
|
42
44
|
Metrics/ModuleLength:
|
43
45
|
CountComments: false # count full line comments?
|
44
46
|
Max: 150
|
47
|
+
|
48
|
+
Lint/EmptyBlock:
|
49
|
+
Enabled: false
|
50
|
+
|
51
|
+
Style/FormatStringToken:
|
52
|
+
Enabled: false
|
53
|
+
|
54
|
+
Style/MixinUsage:
|
55
|
+
Enabled: false
|
56
|
+
|
57
|
+
Lint/ErbNewArguments:
|
58
|
+
Enabled: false
|
59
|
+
|
60
|
+
Style/DocumentDynamicEvalDefinition:
|
61
|
+
Enabled: false
|
62
|
+
|
63
|
+
Naming/HeredocDelimiterNaming:
|
64
|
+
Enabled: false
|
data/.rubocop_todo.yml
CHANGED
@@ -10,12 +10,12 @@ Security/Eval:
|
|
10
10
|
Enabled: false
|
11
11
|
|
12
12
|
# Offense count: 2
|
13
|
-
Lint/
|
13
|
+
Lint/SuppressedException:
|
14
14
|
Enabled: false
|
15
15
|
|
16
16
|
# Offense count: 5
|
17
17
|
Metrics/AbcSize:
|
18
|
-
Max:
|
18
|
+
Max: 30
|
19
19
|
|
20
20
|
# Offense count: 1
|
21
21
|
# Configuration parameters: CountComments.
|
@@ -28,7 +28,7 @@ Metrics/CyclomaticComplexity:
|
|
28
28
|
|
29
29
|
# Offense count: 89
|
30
30
|
# Configuration parameters: AllowURI, URISchemes.
|
31
|
-
|
31
|
+
Layout/LineLength:
|
32
32
|
Max: 242
|
33
33
|
|
34
34
|
# Offense count: 7
|
@@ -41,7 +41,7 @@ Metrics/PerceivedComplexity:
|
|
41
41
|
Max: 14
|
42
42
|
|
43
43
|
# Offense count: 1
|
44
|
-
|
44
|
+
Naming/AccessorMethodName:
|
45
45
|
Enabled: false
|
46
46
|
|
47
47
|
# Offense count: 18
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/History.rdoc
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
=== 4.6.0 / 2021-04-09
|
2
|
+
|
3
|
+
* Fix error with SortedSet on Ruby 3.0 (#98).
|
4
|
+
* Remove `#reset_io` as it didn't do anything.
|
5
|
+
* Drop support for Ruby < 2.4.
|
6
|
+
|
1
7
|
=== 4.5.2 / 2020-03-12
|
2
8
|
|
3
9
|
* Fix bug handling global options provided in option=value form (#47). (@orien)
|
data/Rakefile
CHANGED
data/bin/commander
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'rubygems'
|
4
5
|
require 'commander/import'
|
@@ -97,7 +98,7 @@ command :init do |c|
|
|
97
98
|
File.chmod 0755, file
|
98
99
|
say "Initialized template in #{file}"
|
99
100
|
end
|
100
|
-
rescue => e
|
101
|
+
rescue StandardError => e
|
101
102
|
abort e
|
102
103
|
end
|
103
104
|
end
|
data/commander.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
$LOAD_PATH.push File.expand_path('
|
3
|
+
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
4
4
|
require 'commander/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
@@ -13,12 +13,13 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.summary = 'The complete solution for Ruby command-line executables'
|
14
14
|
s.description = 'The complete solution for Ruby command-line executables. Commander bridges the gap between other terminal related libraries you know and love (OptionParser, HighLine), while providing many new features, and an elegant API.'
|
15
15
|
s.metadata = {
|
16
|
-
'bug_tracker_uri'
|
17
|
-
'changelog_uri'
|
16
|
+
'bug_tracker_uri' => "#{s.homepage}/issues",
|
17
|
+
'changelog_uri' => "#{s.homepage}/blob/master/History.rdoc",
|
18
18
|
'documentation_uri' => "https://www.rubydoc.info/gems/commander/#{s.version}",
|
19
|
-
'homepage_uri'
|
20
|
-
'source_code_uri'
|
19
|
+
'homepage_uri' => s.homepage,
|
20
|
+
'source_code_uri' => "#{s.homepage}/tree/v#{s.version}",
|
21
21
|
}
|
22
|
+
s.required_ruby_version = '>= 2.4'
|
22
23
|
|
23
24
|
s.files = `git ls-files`.split("\n")
|
24
25
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -27,13 +28,8 @@ Gem::Specification.new do |s|
|
|
27
28
|
|
28
29
|
s.add_runtime_dependency('highline', '~> 2.0.0')
|
29
30
|
|
30
|
-
s.add_development_dependency('rspec', '~> 3.2')
|
31
31
|
s.add_development_dependency('rake')
|
32
|
+
s.add_development_dependency('rspec', '~> 3.2')
|
33
|
+
s.add_development_dependency('rubocop', '~> 1.12.1')
|
32
34
|
s.add_development_dependency('simplecov')
|
33
|
-
if RUBY_VERSION < '2.0'
|
34
|
-
s.add_development_dependency('rubocop', '~> 0.41.1')
|
35
|
-
s.add_development_dependency('json', '< 2.0')
|
36
|
-
else
|
37
|
-
s.add_development_dependency('rubocop', '~> 0.49.1')
|
38
|
-
end
|
39
35
|
end
|
data/lib/commander.rb
CHANGED
data/lib/commander/blank.rb
CHANGED
data/lib/commander/command.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'optparse'
|
2
4
|
|
3
5
|
module Commander
|
4
6
|
class Command
|
5
|
-
attr_accessor :name, :examples, :syntax, :description
|
6
|
-
attr_accessor :summary, :proxy_options, :options
|
7
|
+
attr_accessor :name, :examples, :syntax, :description, :summary, :proxy_options, :options
|
7
8
|
attr_reader :global_options
|
8
9
|
|
9
10
|
##
|
@@ -140,6 +141,7 @@ module Commander
|
|
140
141
|
|
141
142
|
def when_called(*args, &block)
|
142
143
|
fail ArgumentError, 'must pass an object, class, or block.' if args.empty? && !block
|
144
|
+
|
143
145
|
@when_called = block ? [block] : args
|
144
146
|
end
|
145
147
|
alias action when_called
|
@@ -163,6 +165,7 @@ module Commander
|
|
163
165
|
|
164
166
|
def parse_options_and_call_procs(*args)
|
165
167
|
return args if args.empty?
|
168
|
+
|
166
169
|
# empty proxy_options before populating via OptionParser
|
167
170
|
# prevents duplication of options if the command is run twice
|
168
171
|
proxy_options.clear
|
@@ -182,8 +185,8 @@ module Commander
|
|
182
185
|
|
183
186
|
case object
|
184
187
|
when Proc then object.call(args, options)
|
185
|
-
when Class then meth
|
186
|
-
else object
|
188
|
+
when Class then meth == :call ? object.new(args, options) : object.new.send(meth, args, options)
|
189
|
+
else object&.send(meth, args, options)
|
187
190
|
end
|
188
191
|
end
|
189
192
|
|
data/lib/commander/configure.rb
CHANGED
data/lib/commander/core_ext.rb
CHANGED
data/lib/commander/delegates.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Commander
|
2
4
|
module Delegates
|
3
5
|
%w(
|
@@ -11,7 +13,7 @@ module Commander
|
|
11
13
|
always_trace!
|
12
14
|
never_trace!
|
13
15
|
).each do |meth|
|
14
|
-
eval <<-END, binding, __FILE__, __LINE__
|
16
|
+
eval <<-END, binding, __FILE__, __LINE__ + 1
|
15
17
|
def #{meth}(*args, &block)
|
16
18
|
::Commander::Runner.instance.#{meth}(*args, &block)
|
17
19
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Commander
|
2
4
|
module HelpFormatter
|
3
5
|
autoload :Base, 'commander/help_formatters/base'
|
@@ -43,7 +45,7 @@ module Commander
|
|
43
45
|
module_function
|
44
46
|
|
45
47
|
def indent(amount, text)
|
46
|
-
text.to_s.gsub("\n", "\n
|
48
|
+
text.to_s.gsub("\n", "\n#{' ' * amount}")
|
47
49
|
end
|
48
50
|
end
|
49
51
|
end
|
data/lib/commander/import.rb
CHANGED
data/lib/commander/methods.rb
CHANGED
data/lib/commander/platform.rb
CHANGED
data/lib/commander/runner.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'optparse'
|
2
4
|
|
3
5
|
module Commander
|
@@ -7,22 +9,10 @@ module Commander
|
|
7
9
|
#++
|
8
10
|
|
9
11
|
class CommandError < StandardError; end
|
10
|
-
class InvalidCommandError < CommandError; end
|
11
|
-
|
12
|
-
##
|
13
|
-
# Array of commands.
|
14
|
-
|
15
|
-
attr_reader :commands
|
16
12
|
|
17
|
-
|
18
|
-
# Global options.
|
19
|
-
|
20
|
-
attr_reader :options
|
21
|
-
|
22
|
-
##
|
23
|
-
# Hash of help formatter aliases.
|
13
|
+
class InvalidCommandError < CommandError; end
|
24
14
|
|
25
|
-
attr_reader :help_formatter_aliases
|
15
|
+
attr_reader :commands, :options, :help_formatter_aliases
|
26
16
|
|
27
17
|
##
|
28
18
|
# Initialize a new command runner. Optionally
|
@@ -41,7 +31,7 @@ module Commander
|
|
41
31
|
# Return singleton Runner instance.
|
42
32
|
|
43
33
|
def self.instance
|
44
|
-
@
|
34
|
+
@instance ||= new
|
45
35
|
end
|
46
36
|
|
47
37
|
##
|
@@ -76,7 +66,7 @@ module Commander
|
|
76
66
|
OptionParser::InvalidArgument,
|
77
67
|
OptionParser::MissingArgument => e
|
78
68
|
abort e.to_s
|
79
|
-
rescue => e
|
69
|
+
rescue StandardError => e
|
80
70
|
if @never_trace
|
81
71
|
abort "error: #{e}."
|
82
72
|
else
|
@@ -231,15 +221,16 @@ module Commander
|
|
231
221
|
# Get active command within arguments passed to this runner.
|
232
222
|
|
233
223
|
def active_command
|
234
|
-
@
|
224
|
+
@active_command ||= command(command_name_from_args)
|
235
225
|
end
|
236
226
|
|
237
227
|
##
|
238
228
|
# Attempts to locate a command name from within the arguments.
|
239
229
|
# Supports multi-word commands, using the largest possible match.
|
230
|
+
# Returns the default command, if no valid commands found in the args.
|
240
231
|
|
241
232
|
def command_name_from_args
|
242
|
-
@
|
233
|
+
@command_name_from_args ||= (longest_valid_command_name_from(@args) || @default_command)
|
243
234
|
end
|
244
235
|
|
245
236
|
##
|
@@ -255,7 +246,7 @@ module Commander
|
|
255
246
|
# Help formatter instance.
|
256
247
|
|
257
248
|
def help_formatter
|
258
|
-
@
|
249
|
+
@help_formatter ||= program(:help_formatter).new self
|
259
250
|
end
|
260
251
|
|
261
252
|
##
|
@@ -304,7 +295,7 @@ module Commander
|
|
304
295
|
if args.empty?
|
305
296
|
say help_formatter.render
|
306
297
|
else
|
307
|
-
command = command
|
298
|
+
command = command(longest_valid_command_name_from(args))
|
308
299
|
begin
|
309
300
|
require_valid_command command
|
310
301
|
rescue InvalidCommandError => e
|
@@ -332,6 +323,7 @@ module Commander
|
|
332
323
|
options.each do |option|
|
333
324
|
switches = option[:switches]
|
334
325
|
next if switches.empty?
|
326
|
+
|
335
327
|
option_takes_argument = switches.any? { |s| s =~ /[ =]/ }
|
336
328
|
switches = expand_optionally_negative_switches(switches)
|
337
329
|
|
@@ -456,5 +448,15 @@ module Commander
|
|
456
448
|
def say(*args) #:nodoc:
|
457
449
|
HighLine.default_instance.say(*args)
|
458
450
|
end
|
451
|
+
|
452
|
+
private
|
453
|
+
|
454
|
+
##
|
455
|
+
# Attempts to locate a command name from within the provided arguments.
|
456
|
+
# Supports multi-word commands, using the largest possible match.
|
457
|
+
|
458
|
+
def longest_valid_command_name_from(args)
|
459
|
+
valid_command_names_from(*args.dup).max
|
460
|
+
end
|
459
461
|
end
|
460
462
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'tempfile'
|
2
4
|
require 'shellwords'
|
3
5
|
|
@@ -218,20 +220,16 @@ module Commander
|
|
218
220
|
#
|
219
221
|
|
220
222
|
def io(input = nil, output = nil, &block)
|
223
|
+
orig_stdin, orig_stdout = $stdin, $stdout
|
221
224
|
$stdin = File.new(input) if input
|
222
225
|
$stdout = File.new(output, 'r+') if output
|
223
226
|
return unless block
|
227
|
+
|
224
228
|
yield
|
229
|
+
$stdin, $stdout = orig_stdin, orig_stdout
|
225
230
|
reset_io
|
226
231
|
end
|
227
232
|
|
228
|
-
##
|
229
|
-
# Reset IO to initial constant streams.
|
230
|
-
|
231
|
-
def reset_io
|
232
|
-
$stdin, $stdout = STDIN, STDOUT
|
233
|
-
end
|
234
|
-
|
235
233
|
##
|
236
234
|
# Find an editor available in path. Optionally supply the _preferred_
|
237
235
|
# editor. Returns the name as a string, nil if none is available.
|
@@ -274,6 +272,7 @@ module Commander
|
|
274
272
|
def enable_paging
|
275
273
|
return unless $stdout.tty?
|
276
274
|
return unless Process.respond_to? :fork
|
275
|
+
|
277
276
|
read, write = IO.pipe
|
278
277
|
|
279
278
|
# Kernel.fork is not supported on all platforms and configurations.
|
@@ -324,7 +323,7 @@ module Commander
|
|
324
323
|
# Implements ask_for_CLASS methods.
|
325
324
|
|
326
325
|
module AskForClass
|
327
|
-
DEPRECATED_CONSTANTS = [
|
326
|
+
DEPRECATED_CONSTANTS = %i[Config TimeoutError MissingSourceFile NIL TRUE FALSE Fixnum Bignum Data].freeze
|
328
327
|
|
329
328
|
# define methods for common classes
|
330
329
|
[Float, Integer, String, Symbol, Regexp, Array, File, Pathname].each do |klass|
|
@@ -338,15 +337,21 @@ module Commander
|
|
338
337
|
if arguments.count != 1
|
339
338
|
fail ArgumentError, "wrong number of arguments (given #{arguments.count}, expected 1)"
|
340
339
|
end
|
340
|
+
|
341
341
|
prompt = arguments.first
|
342
342
|
requested_class = Regexp.last_match[1]
|
343
343
|
|
344
344
|
# All Classes that respond to #parse
|
345
345
|
# Ignore constants that trigger deprecation warnings
|
346
346
|
available_classes = (Object.constants - DEPRECATED_CONSTANTS).map do |const|
|
347
|
-
|
348
|
-
|
349
|
-
|
347
|
+
begin
|
348
|
+
Object.const_get(const)
|
349
|
+
rescue RuntimeError
|
350
|
+
# Rescue errors in Ruby 3 for SortedSet:
|
351
|
+
# The `SortedSet` class has been extracted from the `set` library.
|
352
|
+
end
|
353
|
+
end.compact.select do |const|
|
354
|
+
const.instance_of?(Class) && const.respond_to?(:parse)
|
350
355
|
end
|
351
356
|
|
352
357
|
klass = available_classes.find { |k| k.to_s.downcase == requested_class }
|
@@ -498,7 +503,7 @@ module Commander
|
|
498
503
|
steps_remaining: steps_remaining,
|
499
504
|
total_steps: @total_steps,
|
500
505
|
time_elapsed: format('%0.2fs', time_elapsed),
|
501
|
-
time_remaining: @step
|
506
|
+
time_remaining: @step.positive? ? format('%0.2fs', time_remaining) : '',
|
502
507
|
}.merge! @tokens
|
503
508
|
end
|
504
509
|
|
@@ -507,6 +512,7 @@ module Commander
|
|
507
512
|
|
508
513
|
def show
|
509
514
|
return if finished?
|
515
|
+
|
510
516
|
erase_line
|
511
517
|
if completed?
|
512
518
|
HighLine.default_instance.say UI.replace_tokens(@complete_message, generate_tokens) if @complete_message.is_a? String
|
data/lib/commander/version.rb
CHANGED
data/spec/command_spec.rb
CHANGED
data/spec/configure_spec.rb
CHANGED
data/spec/core_ext/array_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Array do
|
@@ -12,7 +14,7 @@ describe Array do
|
|
12
14
|
|
13
15
|
it 'should match %w behavior with multiple backslashes' do
|
14
16
|
str = 'just a\\ test'
|
15
|
-
expect(Array.parse(str)).to eq(
|
17
|
+
expect(Array.parse(str)).to eq(['just', 'a test'])
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
data/spec/methods_spec.rb
CHANGED
data/spec/runner_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Commander do
|
@@ -484,6 +486,22 @@ describe Commander do
|
|
484
486
|
expect(run('test', '--help')).to eq("Implement help for test here\n")
|
485
487
|
end
|
486
488
|
|
489
|
+
it 'can be used after the command and command arguments' do
|
490
|
+
expect(run('test', 'command-arg', '--help')).to eq("Implement help for test here\n")
|
491
|
+
end
|
492
|
+
|
493
|
+
it 'can be used before a single-word command with command arguments' do
|
494
|
+
expect(run('help', 'test', 'command-arg')).to eq("Implement help for test here\n")
|
495
|
+
end
|
496
|
+
|
497
|
+
it 'can be used before a multi-word command with command arguments' do
|
498
|
+
expect(
|
499
|
+
run('help', 'module', 'install', 'command-arg') do
|
500
|
+
command('module install') { |c| c.when_called { say 'whee!' } }
|
501
|
+
end
|
502
|
+
).to eq("Implement help for module install here\n")
|
503
|
+
end
|
504
|
+
|
487
505
|
describe 'help_paging program information' do
|
488
506
|
it 'enables paging when enabled' do
|
489
507
|
run('--help') { program :help_paging, true }
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rubygems'
|
2
4
|
require 'stringio'
|
3
5
|
require 'simplecov'
|
@@ -6,7 +8,7 @@ SimpleCov.start do
|
|
6
8
|
end
|
7
9
|
|
8
10
|
# Unshift so that local files load instead of something in gems
|
9
|
-
$LOAD_PATH.unshift File.dirname(__FILE__)
|
11
|
+
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
|
10
12
|
|
11
13
|
# This basically replicates the behavior of `require 'commander/import'`
|
12
14
|
# but without adding an `at_exit` hook, which interferes with exit code
|
@@ -49,7 +51,7 @@ end
|
|
49
51
|
# Create a new command runner
|
50
52
|
|
51
53
|
def new_command_runner(*args, &block)
|
52
|
-
Commander::Runner.instance_variable_set
|
54
|
+
Commander::Runner.instance_variable_set :@instance, Commander::Runner.new(args)
|
53
55
|
program :name, 'test'
|
54
56
|
program :version, '1.2.3'
|
55
57
|
program :description, 'something'
|
data/spec/ui_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Commander::UI do
|
@@ -5,7 +7,7 @@ describe Commander::UI do
|
|
5
7
|
|
6
8
|
describe '.replace_tokens' do
|
7
9
|
it 'should replace tokens within a string, with hash values' do
|
8
|
-
result = Commander::UI.replace_tokens 'Welcome :name, enjoy your :object'
|
10
|
+
result = Commander::UI.replace_tokens 'Welcome :name, enjoy your :object', name: 'TJ', object: 'cookie'
|
9
11
|
expect(result).to eq('Welcome TJ, enjoy your cookie')
|
10
12
|
end
|
11
13
|
end
|
@@ -15,7 +17,7 @@ describe Commander::UI do
|
|
15
17
|
exception = false
|
16
18
|
begin
|
17
19
|
progress([]) {}
|
18
|
-
rescue
|
20
|
+
rescue StandardError
|
19
21
|
exception = true
|
20
22
|
end
|
21
23
|
expect(exception).not_to be true
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: commander
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TJ Holowaychuk
|
8
8
|
- Gabriel Gilder
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-04-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: highline
|
@@ -25,6 +25,20 @@ dependencies:
|
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 2.0.0
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
28
42
|
- !ruby/object:Gem::Dependency
|
29
43
|
name: rspec
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -40,19 +54,19 @@ dependencies:
|
|
40
54
|
- !ruby/object:Gem::Version
|
41
55
|
version: '3.2'
|
42
56
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
57
|
+
name: rubocop
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
45
59
|
requirements:
|
46
|
-
- - "
|
60
|
+
- - "~>"
|
47
61
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
62
|
+
version: 1.12.1
|
49
63
|
type: :development
|
50
64
|
prerelease: false
|
51
65
|
version_requirements: !ruby/object:Gem::Requirement
|
52
66
|
requirements:
|
53
|
-
- - "
|
67
|
+
- - "~>"
|
54
68
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
69
|
+
version: 1.12.1
|
56
70
|
- !ruby/object:Gem::Dependency
|
57
71
|
name: simplecov
|
58
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,20 +81,6 @@ dependencies:
|
|
67
81
|
- - ">="
|
68
82
|
- !ruby/object:Gem::Version
|
69
83
|
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.49.1
|
77
|
-
type: :development
|
78
|
-
prerelease: false
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
80
|
-
requirements:
|
81
|
-
- - "~>"
|
82
|
-
- !ruby/object:Gem::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.
|
@@ -143,10 +143,10 @@ licenses:
|
|
143
143
|
metadata:
|
144
144
|
bug_tracker_uri: https://github.com/commander-rb/commander/issues
|
145
145
|
changelog_uri: https://github.com/commander-rb/commander/blob/master/History.rdoc
|
146
|
-
documentation_uri: https://www.rubydoc.info/gems/commander/4.
|
146
|
+
documentation_uri: https://www.rubydoc.info/gems/commander/4.6.0
|
147
147
|
homepage_uri: https://github.com/commander-rb/commander
|
148
|
-
source_code_uri: https://github.com/commander-rb/commander/tree/v4.
|
149
|
-
post_install_message:
|
148
|
+
source_code_uri: https://github.com/commander-rb/commander/tree/v4.6.0
|
149
|
+
post_install_message:
|
150
150
|
rdoc_options: []
|
151
151
|
require_paths:
|
152
152
|
- lib
|
@@ -154,15 +154,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
154
154
|
requirements:
|
155
155
|
- - ">="
|
156
156
|
- !ruby/object:Gem::Version
|
157
|
-
version: '
|
157
|
+
version: '2.4'
|
158
158
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
159
|
requirements:
|
160
160
|
- - ">="
|
161
161
|
- !ruby/object:Gem::Version
|
162
162
|
version: '0'
|
163
163
|
requirements: []
|
164
|
-
rubygems_version: 3.
|
165
|
-
signing_key:
|
164
|
+
rubygems_version: 3.2.15
|
165
|
+
signing_key:
|
166
166
|
specification_version: 4
|
167
167
|
summary: The complete solution for Ruby command-line executables
|
168
168
|
test_files:
|