method
invoke
v7.0.0 -
Show latest stable
- Class:
Rails::Command
invoke(full_namespace, args = [], **config)public
Receives a namespace, arguments and the behavior to invoke the command.
# File railties/lib/rails/command.rb, line 30
def invoke(full_namespace, args = [], **config)
namespace = full_namespace = full_namespace.to_s
if char = namespace =~ /:(\w+)$/
command_name, namespace = $1, namespace.slice(0, char)
else
command_name = namespace
end
command_name, namespace = "help", "help" if command_name.blank? || HELP_MAPPINGS.include?(command_name)
command_name, namespace, args = "application", "application", ["--help"] if rails_new_with_no_path?(args)
command_name, namespace = "version", "version" if %( -v --version ).include?(command_name)
original_argv = ARGV.dup
ARGV.replace(args)
command = find_by_namespace(namespace, command_name)
if command && command.all_commands[command_name]
command.perform(command_name, args, config)
else
args = ["--describe", full_namespace] if HELP_MAPPINGS.include?(args[0])
find_by_namespace("rake").perform(full_namespace, args, config)
end
ensure
ARGV.replace(original_argv)
end Related methods
- Class methods
- environment
- find_by_namespace
- hidden_commands
- invoke
- print_commands
- root
- Private methods
-
command_type -
commands -
file_lookup_paths -
lookup_paths -
rails_new_with_no_path?