thor-plus 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/thor.rb +13 -12
  3. data/lib/thor/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3dfe41e5f6475c9cecd7c40a7d1b821c0a3c9aa5
4
- data.tar.gz: 3ae375b919909902c286778693db87b98b0c9991
3
+ metadata.gz: 58295881823689f3350e642f849fb6ad397b95fe
4
+ data.tar.gz: 248bd3a87c889ac1f43b5e99db1765d84435389d
5
5
  SHA512:
6
- metadata.gz: af4e05abca2333347f3664485b64bb230bc306bc39fe0c896bd66898c9d576f90734d4436bf4ca3c4902ee1a348ede0bd2139052d36338d80929ed05eb22ed6e
7
- data.tar.gz: 8915fb4d9d2e5e0dd75651bca6e3736a7194550aa2d732a87ce6a793dce97a28cc9680b6240e95be733837aded349e11a495a503789943849b719a5b940ce6fa
6
+ metadata.gz: 24b141e2f026d2317beef2852775840d593163e84310ece4e50301c5d4e0440477aca6943f46a57eacc8db884fb777dfff04e50d6f33cf0c6eb958ff5d43438e
7
+ data.tar.gz: 697de57d139368376a2701e68c2d4e3be36fa48135858873d9cc51a3089974c59b3efe56c9a3f835603adfd27d5472f79e7ab0ab47d51314058c58d9c2f92f9f
@@ -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
- @package_name = name.nil? || name == "" ? nil : name
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
- if defined?(@package_name) && @package_name
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
- "#{basename} #{command.formatted_usage(self, $thor_runner, subcommand)}"
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)
@@ -1,3 +1,3 @@
1
1
  class Thor
2
- VERSION = "0.3.1"
2
+ VERSION = "0.5.0"
3
3
  end
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.3.1
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-10 00:00:00.000000000 Z
13
+ date: 2016-06-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler