Sha256: 37f73622be43afec78ee8b7435922e87957f2311e9c34a653cd4fcc9a8baefd5

Contents?: true

Size: 714 Bytes

Versions: 34

Compression:

Stored size: 714 Bytes

Contents

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

class Thor
  class << self
    attr_accessor :parent_class

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

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

    alias :old_subcommand :subcommand

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

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
cloudstack-cli-1.6.10 lib/cloudstack-cli/thor_patch.rb
cloudstack-cli-1.6.9 lib/cloudstack-cli/thor_patch.rb
cloudstack-cli-1.6.8 lib/cloudstack-cli/thor_patch.rb
cloudstack-cli-1.6.7 lib/cloudstack-cli/thor_patch.rb
cloudstack-cli-1.6.6 lib/cloudstack-cli/thor_patch.rb
cloudstack-cli-1.6.5 lib/cloudstack-cli/thor_patch.rb
cloudstack-cli-1.6.4 lib/cloudstack-cli/thor_patch.rb
cloudstack-cli-1.6.3 lib/cloudstack-cli/thor_patch.rb
cloudstack-cli-1.6.2 lib/cloudstack-cli/thor_patch.rb
cloudstack-cli-1.6.1 lib/cloudstack-cli/thor_patch.rb
cloudstack-cli-1.6.0 lib/cloudstack-cli/thor_patch.rb
cloudstack-cli-1.5.13 lib/cloudstack-cli/thor_patch.rb
cloudstack-cli-1.5.12 lib/cloudstack-cli/thor_patch.rb
cloudstack-cli-1.5.10 lib/cloudstack-cli/thor_patch.rb
cloudstack-cli-1.5.9 lib/cloudstack-cli/thor_patch.rb
cloudstack-cli-1.5.8 lib/cloudstack-cli/thor_patch.rb
cloudstack-cli-1.5.7 lib/cloudstack-cli/thor_patch.rb
cloudstack-cli-1.5.6 lib/cloudstack-cli/thor_patch.rb
cloudstack-cli-1.5.5 lib/cloudstack-cli/thor_patch.rb
cloudstack-cli-1.5.4 lib/cloudstack-cli/thor_patch.rb