class Rails::Command::Base

def banner(*)

Use Rails' default banner.
def banner(*)
  "#{executable} #{arguments.map(&:usage).join(' ')} [options]".squish
end

def base_name

Rails::Command::TestCommand.base_name # => 'rails'

Sets the base_name taking into account the current class namespace.
def base_name
  @base_name ||= if base = name.to_s.split("::").first
    base.underscore
  end
end

def command_name

Rails::Command::TestCommand.command_name # => 'test'

Return command name without namespaces.
def command_name
  @command_name ||= if command = name.to_s.split("::").last
    command.chomp!("Command")
    command.underscore
  end
end

def command_root_namespace

def command_root_namespace
  (namespace.split(":") - %w(rails)).join(":")
end

def create_command(meth)

Allow the command method to be called perform.
def create_command(meth)
  if meth == "perform"
    alias_method command_name, meth
  else
    # Prevent exception about command without usage.
    # Some commands define their documentation differently.
    @usage ||= ""
    @desc  ||= ""
    super
  end
end

def default_command_root

would return rails/test.
For a Rails::Command::TestCommand placed in rails/command/test_command.rb

one folder above the command file.
Default file root to place extra files a command might need, placed
def default_command_root
  path = File.expand_path(relative_command_path, __dir__)
  path if File.exist?(path)
end

def desc(usage = nil, description = nil, options = {})

root.
Tries to get the description from a USAGE file one folder above the command
def desc(usage = nil, description = nil, options = {})
  if usage
    super
  else
    @desc ||= ERB.new(File.read(usage_path), trim_mode: "-").result(binding) if usage_path
  end
end

def engine?

Returns true when the app is a Rails engine.
def engine?
  defined?(ENGINE_ROOT)
end

def executable

def executable
  "rails #{command_name}"
end

def exit_on_failure? # :nodoc:

:nodoc:
def exit_on_failure? # :nodoc:
  false
end

def help

def help
  if command_name = self.class.command_name
    self.class.command_help(shell, command_name)
  else
    super
  end
end

def hide_command!

running rails command.
Convenience method to hide this command from the available ones when
def hide_command!
  Rails::Command.hidden_commands << self
end

def inherited(base) # :nodoc:

:nodoc:
def inherited(base) # :nodoc:
  super
  if base.name && !base.name.end_with?("Base")
    Rails::Command.subclasses << base
  end
end

def namespace(name = nil)

is removed.
same as Thor default except that the Command at the end of the class
Convenience method to get the namespace from the class name. It's the
def namespace(name = nil)
  if name
    super
  else
    @namespace ||= super.chomp("_command").sub(/:command:/, ":")
  end
end

def namespaced_commands

def namespaced_commands
  commands.keys.map do |key|
    if command_root_namespace.match?(/(\A|:)#{key}\z/)
      command_root_namespace
    else
      "#{command_root_namespace}:#{key}"
    end
  end
end

def perform(command, args, config) # :nodoc:

:nodoc:
def perform(command, args, config) # :nodoc:
  if Rails::Command::HELP_MAPPINGS.include?(args.first)
    command, args = "help", []
  end
  dispatch(command, args.dup, nil, config)
end

def printing_commands

def printing_commands
  namespaced_commands
end

def relative_command_path

def relative_command_path
  File.join("../commands", *command_root_namespace.split(":"))
end

def usage_path

Path to lookup a USAGE description in a file.
def usage_path
  if default_command_root
    path = File.join(default_command_root, "USAGE")
    path if File.exist?(path)
  end
end