class DLDInternet::Thor::Command

Attributes

invocations[RW]
cassette[R]
format[RW]
formatter[RW]
header[RW]
vcr_logger[R]
writer[RW]

Public Class Methods

command_help(shell, command_name, invocations=[]) click to toggle source

def command(scommand, usage, description, options = {}, &block)

desc usage, description, options
define_method(scommand) do |*args|
  args, opts = ::Thor::Arguments.split(args)
  block.call(args)
end

end alias_method :task, :command

Calls superclass method
# File lib/dldinternet/thor/command.rb, line 35
def command_help(shell, command_name, invocations=[])
  super(shell, command_name)
  0
end
namespace() click to toggle source
# File lib/dldinternet/thor/command.rb, line 21
def namespace
  parts = self.name.split(/::/)
  parts[parts.size > 2 ? -2 : -1].downcase
end
new(args = [], local_options = {}, config = {}) click to toggle source
Calls superclass method
# File lib/dldinternet/thor/command.rb, line 69
def initialize(args = [], local_options = {}, config = {})
  super(args,local_options,config)
  @log_level = :warn #|| @config[:log_level].to_sym
  @formatter ||= ->(hsh, opts) {
    default_formatter(hsh, opts)
  }
  @writer    ||= ->(str) {
    puts str
  }
  @header ||= ->(res, fmtr=nil) {
    default_header(res, fmtr)
  }
  @format ||= ->(res, fmtr=nil) {
    default_format(res, nil, fmtr)
  }
end

Protected Class Methods

banner(command, namespace = nil, subcommand = false) click to toggle source

Public Instance Methods

help(command = nil, subcommand = false) click to toggle source
Calls superclass method
# File lib/dldinternet/thor/command.rb, line 87
def help(command = nil, subcommand = false)
  ::DLDInternet::Thor::Command.invocations = @_invocations.dup.map{ |_,v| v[0]}
  # self.class.invocations[-1] = command
  ::DLDInternet::Thor::Command.invocations.pop if ::DLDInternet::Thor::Command.invocations[-1].eql?('help')
  ::DLDInternet::Thor::Command.invocations.pop if ::DLDInternet::Thor::Command.invocations[-1].eql?(command) || (!command && subcommand)
  super(command, subcommand)
  # if command
  #   if self.class.subcommands.include? command
  #     self.class.subcommand_classes[command].help(shell, true)
  #   else
  #     self.class.command_help(shell, command, invocations)
  #   end
  # else
  #   self.class.help(shell, subcommand)
  # end
  0
end