class method self.invoke

Ruby on Rails 6.1.7.10

Since v5.2.8.1

Available in: v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

self.invoke(full_namespace, args = [], **config)

Receives a namespace, arguments and the behavior to invoke the command.

Parameters

full_namespace req
args opt = []
config keyrest
Source
# File railties/lib/rails/command.rb, line 31
      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 = "version", "version" if %w( -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
          find_by_namespace("rake").perform(full_namespace, args, config)
        end
      ensure
        ARGV.replace(original_argv)
      end

Defined in railties/lib/rails/command.rb line 31 · View on GitHub · Improve this page · Find usages on GitHub

Defined in Rails::Command

Type at least 2 characters to search.

↑↓ navigate · open · esc close