Class: Thor

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudstack-cli/thor_patch.rb

Overview

Fixes thor help for subcommands github.com/erikhuda/thor/pull/330

Direct Known Subclasses

CloudstackCli::Base

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.parent_classObject

Returns the value of attribute parent_class.



6
7
8
# File 'lib/cloudstack-cli/thor_patch.rb', line 6

def parent_class
  @parent_class
end

Class Method Details



15
16
17
# File 'lib/cloudstack-cli/thor_patch.rb', line 15

def banner(command, namespace = nil, subcommand = false)
  "#{basename2(subcommand)} #{command.formatted_usage(self, $thor_runner, subcommand)}"
end

.basename2(subcommand = false) ⇒ Object



8
9
10
11
12
13
# File 'lib/cloudstack-cli/thor_patch.rb', line 8

def basename2(subcommand = false)
  bn  = parent_class && parent_class.basename2
  bn2 = basename
  ns  = self.namespace.split(':').last
  bn ? (subcommand ? bn : "#{bn} #{ns}") : bn2
end

.old_subcommandObject



19
# File 'lib/cloudstack-cli/thor_patch.rb', line 19

alias :old_subcommand :subcommand

.subcommand(subcommand, subcommand_class) ⇒ Object



21
22
23
24
# File 'lib/cloudstack-cli/thor_patch.rb', line 21

def subcommand(subcommand, subcommand_class)
  subcommand_class.parent_class = self
  old_subcommand(subcommand, subcommand_class)
end