thor-plus 0.3.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/thor.rb +13 -12
- data/lib/thor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58295881823689f3350e642f849fb6ad397b95fe
|
4
|
+
data.tar.gz: 248bd3a87c889ac1f43b5e99db1765d84435389d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24b141e2f026d2317beef2852775840d593163e84310ece4e50301c5d4e0440477aca6943f46a57eacc8db884fb777dfff04e50d6f33cf0c6eb958ff5d43438e
|
7
|
+
data.tar.gz: 697de57d139368376a2701e68c2d4e3be36fa48135858873d9cc51a3089974c59b3efe56c9a3f835603adfd27d5472f79e7ab0ab47d51314058c58d9c2f92f9f
|
data/lib/thor.rb
CHANGED
@@ -14,8 +14,12 @@ class Thor # rubocop:disable ClassLength
|
|
14
14
|
# name<String>
|
15
15
|
# options<Hash>
|
16
16
|
#
|
17
|
-
def package_name(name, options = {})
|
18
|
-
|
17
|
+
def package_name(name = nil, options = {})
|
18
|
+
if name
|
19
|
+
@package_name = name.nil? || name == "" ? nil : name
|
20
|
+
else
|
21
|
+
@package_name ||= basename
|
22
|
+
end
|
19
23
|
end
|
20
24
|
|
21
25
|
# Sets the default command when thor is executed without an explicit command to be called.
|
@@ -189,13 +193,13 @@ class Thor # rubocop:disable ClassLength
|
|
189
193
|
# shell<Thor::Shell>
|
190
194
|
# command_name<String>
|
191
195
|
#
|
192
|
-
def command_help(shell, command_name)
|
196
|
+
def command_help(shell, command_name, subcommand = false)
|
193
197
|
meth = normalize_command_name(command_name)
|
194
198
|
command = all_commands[meth]
|
195
199
|
handle_no_command_error(meth) unless command
|
196
200
|
|
197
201
|
shell.say "Usage:"
|
198
|
-
shell.say " #{banner(command)}"
|
202
|
+
shell.say " #{banner(command, nil, subcommand)}"
|
199
203
|
shell.say
|
200
204
|
class_options_help(shell, nil => command.options.values)
|
201
205
|
if command.long_description
|
@@ -219,12 +223,7 @@ class Thor # rubocop:disable ClassLength
|
|
219
223
|
end
|
220
224
|
list.sort! { |a, b| a[0] <=> b[0] }
|
221
225
|
|
222
|
-
|
223
|
-
shell.say "#{@package_name} commands:"
|
224
|
-
else
|
225
|
-
shell.say "Commands:"
|
226
|
-
end
|
227
|
-
|
226
|
+
shell.say "#{package_name} commands:"
|
228
227
|
shell.print_table(list, :indent => 2, :truncate => true)
|
229
228
|
shell.say
|
230
229
|
class_options_help(shell)
|
@@ -253,6 +252,7 @@ class Thor # rubocop:disable ClassLength
|
|
253
252
|
|
254
253
|
def subcommand(subcommand, subcommand_class)
|
255
254
|
subcommands << subcommand.to_s
|
255
|
+
subcommand_class.package_name(self.package_name)
|
256
256
|
subcommand_class.subcommand_help subcommand
|
257
257
|
subcommand_classes[subcommand.to_s] = subcommand_class
|
258
258
|
|
@@ -394,7 +394,7 @@ class Thor # rubocop:disable ClassLength
|
|
394
394
|
# the namespace should be displayed as arguments.
|
395
395
|
#
|
396
396
|
def banner(command, namespace = nil, subcommand = false)
|
397
|
-
"#{
|
397
|
+
"#{package_name} #{command.formatted_usage(self, $thor_runner, subcommand)}"
|
398
398
|
end
|
399
399
|
|
400
400
|
def baseclass #:nodoc:
|
@@ -489,6 +489,7 @@ class Thor # rubocop:disable ClassLength
|
|
489
489
|
def subcommand_help(cmd)
|
490
490
|
desc "help [COMMAND]", "Describe subcommands or one specific subcommand"
|
491
491
|
class_eval "
|
492
|
+
disable_class_options
|
492
493
|
def help(command = nil, subcommand = true); super; end
|
493
494
|
"
|
494
495
|
end
|
@@ -506,7 +507,7 @@ class Thor # rubocop:disable ClassLength
|
|
506
507
|
if self.class.subcommands.include? command
|
507
508
|
self.class.subcommand_classes[command].help(shell, true)
|
508
509
|
else
|
509
|
-
self.class.command_help(shell, command)
|
510
|
+
self.class.command_help(shell, command, subcommand)
|
510
511
|
end
|
511
512
|
else
|
512
513
|
self.class.help(shell, subcommand)
|
data/lib/thor/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thor-plus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yehuda Katz
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-06-
|
13
|
+
date: 2016-06-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|