diff options
Diffstat (limited to 'railties/lib/rails/command/base.rb')
-rw-r--r-- | railties/lib/rails/command/base.rb | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/railties/lib/rails/command/base.rb b/railties/lib/rails/command/base.rb index db20c71861..766872de8a 100644 --- a/railties/lib/rails/command/base.rb +++ b/railties/lib/rails/command/base.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "thor" require "erb" @@ -64,16 +66,16 @@ module Rails end def printing_commands - namespace.sub(/^rails:/, "") + namespaced_commands end def executable - "bin/rails #{command_name}" + "rails #{command_name}" end # Use Rails' default banner. def banner(*) - "#{executable} #{arguments.map(&:usage).join(' ')} [options]".squish! + "#{executable} #{arguments.map(&:usage).join(' ')} [options]".squish end # Sets the base_name taking into account the current class namespace. @@ -110,8 +112,8 @@ module Rails # Default file root to place extra files a command might need, placed # one folder above the command file. # - # For a `Rails::Command::TestCommand` placed in `rails/command/test_command.rb` - # would return `rails/test`. + # For a Rails::Command::TestCommand placed in <tt>rails/command/test_command.rb</tt> + # would return <tt>rails/test</tt>. def default_command_root path = File.expand_path(File.join("../commands", command_root_namespace), __dir__) path if File.exist?(path) @@ -135,6 +137,12 @@ module Rails def command_root_namespace (namespace.split(":") - %w( rails )).first end + + def namespaced_commands + commands.keys.map do |key| + key == command_root_namespace ? key : "#{command_root_namespace}:#{key}" + end + end end def help |