aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/command.rb
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2017-02-23 15:01:02 +0100
committerDavid Heinemeier Hansson <david@loudthinking.com>2017-02-23 15:01:02 +0100
commit11660945696155c86a05260795e1a0afce0d291d (patch)
tree78f546f5b80c8ab4f01ff68bf5945d1a58a74e45 /railties/lib/rails/command.rb
parentfd85bec26148e05a8e3d546c2827c889f9a9f8f8 (diff)
downloadrails-11660945696155c86a05260795e1a0afce0d291d.tar.gz
rails-11660945696155c86a05260795e1a0afce0d291d.tar.bz2
rails-11660945696155c86a05260795e1a0afce0d291d.zip
Add encrypted secrets (#28038)
Diffstat (limited to 'railties/lib/rails/command.rb')
-rw-r--r--railties/lib/rails/command.rb27
1 files changed, 18 insertions, 9 deletions
diff --git a/railties/lib/rails/command.rb b/railties/lib/rails/command.rb
index 13f3b90b6d..73f9684ca4 100644
--- a/railties/lib/rails/command.rb
+++ b/railties/lib/rails/command.rb
@@ -27,15 +27,22 @@ 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)
+
+ if command = find_by_namespace(namespace, command_name)
+ command.perform(command_name, args, config)
+ else
+ find_by_namespace("rake").perform(full_namespace, args, config)
end
end
@@ -52,8 +59,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)