thor 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/thor.rb +5 -6
- data/lib/thor/actions.rb +1 -1
- data/lib/thor/actions/file_manipulation.rb +4 -2
- data/lib/thor/error.rb +1 -1
- data/lib/thor/parser/arguments.rb +5 -1
- data/lib/thor/parser/options.rb +9 -8
- data/lib/thor/shell/basic.rb +5 -2
- data/lib/thor/shell/color.rb +5 -1
- data/lib/thor/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49e18474eddb5dbf02c13be5b42104385928e460511272e7293cc66110d1c3d7
|
4
|
+
data.tar.gz: ffea33d8f08051882551af3a444fe68a77ffe0ecfe16404f2ead662364d36b5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc1a58088c4c7b48166152c1f7cfc0c4dc91e9c3199e583e6085b74a2982f65c0eaa8d8b7595f8f5781c08b0f60818e4a014bb23adbdfb07fd2ded558ceef67e
|
7
|
+
data.tar.gz: f9a3c7f81a55d75298e3655569a86f04aa2055088058eb0a30ce5b80e05c6be7ed9c0f1840031dd266c453a4ac1454d8749849b47659d2f53f8b1221b9db2b7b
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# 1.1.0
|
2
|
+
* Don't use ANSI colors when terminal is dumb.
|
3
|
+
* Ensure default option/argument is not erroneously aliased.
|
4
|
+
* Fixes a bug in the calculation of the print_wrapped method.
|
5
|
+
* Obey `:mute` and `options[:quiet]` in `Shell#say`.
|
6
|
+
* Support Ruby 3.0.
|
7
|
+
* Add force option to the `gsub_file` action.
|
8
|
+
|
1
9
|
# 1.0.1
|
2
10
|
* Fix thor when `thor/base` and `thor/group` are required without `thor.rb`.
|
3
11
|
* Handle relative source path in `create_link`.
|
data/lib/thor.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require "set"
|
2
1
|
require_relative "thor/base"
|
3
2
|
|
4
3
|
class Thor
|
4
|
+
$thor_runner ||= false
|
5
5
|
class << self
|
6
6
|
# Allows for custom "Command" package naming.
|
7
7
|
#
|
@@ -323,7 +323,7 @@ class Thor
|
|
323
323
|
# ==== Parameters
|
324
324
|
# Symbol ...:: A list of commands that should be affected.
|
325
325
|
def stop_on_unknown_option!(*command_names)
|
326
|
-
stop_on_unknown_option
|
326
|
+
@stop_on_unknown_option = stop_on_unknown_option | command_names
|
327
327
|
end
|
328
328
|
|
329
329
|
def stop_on_unknown_option?(command) #:nodoc:
|
@@ -337,7 +337,7 @@ class Thor
|
|
337
337
|
# ==== Parameters
|
338
338
|
# Symbol ...:: A list of commands that should be affected.
|
339
339
|
def disable_required_check!(*command_names)
|
340
|
-
disable_required_check
|
340
|
+
@disable_required_check = disable_required_check | command_names
|
341
341
|
end
|
342
342
|
|
343
343
|
def disable_required_check?(command) #:nodoc:
|
@@ -347,12 +347,12 @@ class Thor
|
|
347
347
|
protected
|
348
348
|
|
349
349
|
def stop_on_unknown_option #:nodoc:
|
350
|
-
@stop_on_unknown_option ||=
|
350
|
+
@stop_on_unknown_option ||= []
|
351
351
|
end
|
352
352
|
|
353
353
|
# help command has the required check disabled by default.
|
354
354
|
def disable_required_check #:nodoc:
|
355
|
-
@disable_required_check ||=
|
355
|
+
@disable_required_check ||= [:help]
|
356
356
|
end
|
357
357
|
|
358
358
|
# The method responsible for dispatching given the args.
|
@@ -398,7 +398,6 @@ class Thor
|
|
398
398
|
# the namespace should be displayed as arguments.
|
399
399
|
#
|
400
400
|
def banner(command, namespace = nil, subcommand = false)
|
401
|
-
$thor_runner ||= false
|
402
401
|
command.formatted_usage(self, $thor_runner, subcommand).split("\n").map do |formatted_usage|
|
403
402
|
"#{basename} #{formatted_usage}"
|
404
403
|
end.join("\n")
|
data/lib/thor/actions.rb
CHANGED
@@ -251,7 +251,8 @@ class Thor
|
|
251
251
|
# path<String>:: path of the file to be changed
|
252
252
|
# flag<Regexp|String>:: the regexp or string to be replaced
|
253
253
|
# replacement<String>:: the replacement, can be also given as a block
|
254
|
-
# config<Hash>:: give :verbose => false to not log the status
|
254
|
+
# config<Hash>:: give :verbose => false to not log the status, and
|
255
|
+
# :force => true, to force the replacement regardles of runner behavior.
|
255
256
|
#
|
256
257
|
# ==== Example
|
257
258
|
#
|
@@ -262,9 +263,10 @@ class Thor
|
|
262
263
|
# end
|
263
264
|
#
|
264
265
|
def gsub_file(path, flag, *args, &block)
|
265
|
-
return unless behavior == :invoke
|
266
266
|
config = args.last.is_a?(Hash) ? args.pop : {}
|
267
267
|
|
268
|
+
return unless behavior == :invoke || config.fetch(:force, false)
|
269
|
+
|
268
270
|
path = File.expand_path(path, destination_root)
|
269
271
|
say_status :gsub, relative_to_original_destination_root(path), config.fetch(:verbose, true)
|
270
272
|
|
data/lib/thor/error.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class Thor
|
2
|
-
Correctable = if defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable)
|
2
|
+
Correctable = if defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable) # rubocop:disable Naming/ConstantName
|
3
3
|
# In order to support versions of Ruby that don't have keyword
|
4
4
|
# arguments, we need our own spell checker class that doesn't take key
|
5
5
|
# words. Even though this code wouldn't be hit because of the check
|
@@ -30,7 +30,11 @@ class Thor
|
|
30
30
|
|
31
31
|
arguments.each do |argument|
|
32
32
|
if !argument.default.nil?
|
33
|
-
|
33
|
+
begin
|
34
|
+
@assigns[argument.human_name] = argument.default.dup
|
35
|
+
rescue TypeError # Compatibility shim for un-dup-able Fixnum in Ruby < 2.4
|
36
|
+
@assigns[argument.human_name] = argument.default
|
37
|
+
end
|
34
38
|
elsif argument.required?
|
35
39
|
@non_assigned_required << argument
|
36
40
|
end
|
data/lib/thor/parser/options.rb
CHANGED
@@ -133,15 +133,16 @@ class Thor
|
|
133
133
|
|
134
134
|
protected
|
135
135
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
136
|
+
def assign_result!(option, result)
|
137
|
+
if option.repeatable && option.type == :hash
|
138
|
+
(@assigns[option.human_name] ||= {}).merge!(result)
|
139
|
+
elsif option.repeatable
|
140
|
+
(@assigns[option.human_name] ||= []) << result
|
141
|
+
else
|
142
|
+
@assigns[option.human_name] = result
|
143
|
+
end
|
143
144
|
end
|
144
|
-
|
145
|
+
|
145
146
|
# Check if the current value in peek is a registered switch.
|
146
147
|
#
|
147
148
|
# Two booleans are returned. The first is true if the current value
|
data/lib/thor/shell/basic.rb
CHANGED
@@ -94,6 +94,8 @@ class Thor
|
|
94
94
|
# say("I know you knew that.")
|
95
95
|
#
|
96
96
|
def say(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
|
97
|
+
return if quiet?
|
98
|
+
|
97
99
|
buffer = prepare_message(message, *color)
|
98
100
|
buffer << "\n" if force_new_line && !message.to_s.end_with?("\n")
|
99
101
|
|
@@ -230,8 +232,9 @@ class Thor
|
|
230
232
|
paras = message.split("\n\n")
|
231
233
|
|
232
234
|
paras.map! do |unwrapped|
|
233
|
-
|
234
|
-
|
235
|
+
words = unwrapped.split(" ")
|
236
|
+
counter = words.first.length
|
237
|
+
words.inject do |memo, word|
|
235
238
|
word = word.gsub(/\n\005/, "\n").gsub(/\005/, "\n")
|
236
239
|
counter = 0 if word.include? "\n"
|
237
240
|
if (counter + word.length + 1) < width
|
data/lib/thor/shell/color.rb
CHANGED
@@ -97,7 +97,11 @@ class Thor
|
|
97
97
|
protected
|
98
98
|
|
99
99
|
def can_display_colors?
|
100
|
-
|
100
|
+
are_colors_supported? && !are_colors_disabled?
|
101
|
+
end
|
102
|
+
|
103
|
+
def are_colors_supported?
|
104
|
+
stdout.tty? && ENV["TERM"] != "dumb"
|
101
105
|
end
|
102
106
|
|
103
107
|
def are_colors_disabled?
|
data/lib/thor/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yehuda Katz
|
8
8
|
- José Valim
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-01-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -83,9 +83,9 @@ metadata:
|
|
83
83
|
bug_tracker_uri: https://github.com/erikhuda/thor/issues
|
84
84
|
changelog_uri: https://github.com/erikhuda/thor/blob/master/CHANGELOG.md
|
85
85
|
documentation_uri: http://whatisthor.com/
|
86
|
-
source_code_uri: https://github.com/erikhuda/thor/tree/v1.0
|
86
|
+
source_code_uri: https://github.com/erikhuda/thor/tree/v1.1.0
|
87
87
|
wiki_uri: https://github.com/erikhuda/thor/wiki
|
88
|
-
post_install_message:
|
88
|
+
post_install_message:
|
89
89
|
rdoc_options: []
|
90
90
|
require_paths:
|
91
91
|
- lib
|
@@ -100,8 +100,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: 1.3.5
|
102
102
|
requirements: []
|
103
|
-
rubygems_version: 3.
|
104
|
-
signing_key:
|
103
|
+
rubygems_version: 3.2.3
|
104
|
+
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: Thor is a toolkit for building powerful command-line interfaces.
|
107
107
|
test_files: []
|