diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2017-02-23 19:22:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-23 19:22:55 +0100 |
commit | 8f59a1dd878f56798f88369fa5b448f17a29679d (patch) | |
tree | 5ba674c73ffb5e2f246e7a2d0a8db579733d37f5 /railties/lib/rails/command.rb | |
parent | 4734d23c74fb4193aafe7cb04256bb745680d97f (diff) | |
parent | 9fdf326a5f6f7e10594dd6205cfc8e0425fb3e67 (diff) | |
download | rails-8f59a1dd878f56798f88369fa5b448f17a29679d.tar.gz rails-8f59a1dd878f56798f88369fa5b448f17a29679d.tar.bz2 rails-8f59a1dd878f56798f88369fa5b448f17a29679d.zip |
Merge pull request #28128 from rails/revert-28127-revert-28038-encrypted-secrets
Revert "Revert "Add encrypted secrets""
Diffstat (limited to 'railties/lib/rails/command.rb')
-rw-r--r-- | railties/lib/rails/command.rb | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/railties/lib/rails/command.rb b/railties/lib/rails/command.rb index 13f3b90b6d..d8549db62e 100644 --- a/railties/lib/rails/command.rb +++ b/railties/lib/rails/command.rb @@ -27,15 +27,23 @@ module Rails end # Receives a namespace, arguments and the behavior to invoke the command. - def invoke(namespace, args = [], **config) - namespace = namespace.to_s - namespace = "help" if namespace.blank? || HELP_MAPPINGS.include?(namespace) - namespace = "version" if %w( -v --version ).include? namespace + def invoke(full_namespace, args = [], **config) + namespace = full_namespace = full_namespace.to_s - if command = find_by_namespace(namespace) - command.perform(namespace, args, config) + if char = namespace =~ /:(\w+)$/ + command_name, namespace = $1, namespace.slice(0, char) else - find_by_namespace("rake").perform(namespace, args, config) + command_name = namespace + end + + command_name = "help" if command_name.blank? || HELP_MAPPINGS.include?(command_name) + namespace = "version" if %w( -v --version ).include?(command_name) + + 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 end @@ -52,8 +60,10 @@ module Rails # # Notice that "rails:commands:webrat" could be loaded as well, what # Rails looks for is the first and last parts of the namespace. - def find_by_namespace(name) # :nodoc: - lookups = [ name, "rails:#{name}" ] + def find_by_namespace(namespace, command_name = nil) # :nodoc: + lookups = [ namespace ] + lookups << "#{namespace}:#{command_name}" if command_name + lookups.concat lookups.map { |lookup| "rails:#{lookup}" } lookup(lookups) |