diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2017-03-09 20:27:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-09 20:27:39 +0100 |
commit | 9f9e57339bb88fcf5f8e47a048d8201b97cd5f53 (patch) | |
tree | 5c2f2d9ffcbdfd8cfe6e243e04391b10df003343 | |
parent | b16dcc872bb3c094cf1f1d890bdd302593acbbe8 (diff) | |
parent | 54ee15a203d7463534c2188141c6fb0090c9dc44 (diff) | |
download | rails-9f9e57339bb88fcf5f8e47a048d8201b97cd5f53.tar.gz rails-9f9e57339bb88fcf5f8e47a048d8201b97cd5f53.tar.bz2 rails-9f9e57339bb88fcf5f8e47a048d8201b97cd5f53.zip |
Merge pull request #28182 from y-yagi/show_correct_rails_commands
Show correct commands in help
-rw-r--r-- | railties/lib/rails/command/base.rb | 8 | ||||
-rw-r--r-- | railties/lib/rails/commands/destroy/destroy_command.rb | 6 | ||||
-rw-r--r-- | railties/lib/rails/commands/generate/generate_command.rb | 10 | ||||
-rw-r--r-- | railties/lib/rails/commands/new/new_command.rb | 6 | ||||
-rw-r--r-- | railties/lib/rails/commands/runner/runner_command.rb | 8 | ||||
-rw-r--r-- | railties/lib/rails/commands/secrets/secrets_command.rb | 10 | ||||
-rw-r--r-- | railties/lib/rails/commands/test/test_command.rb | 6 | ||||
-rw-r--r-- | railties/test/command/base_test.rb | 11 |
8 files changed, 47 insertions, 18 deletions
diff --git a/railties/lib/rails/command/base.rb b/railties/lib/rails/command/base.rb index db20c71861..4f074df473 100644 --- a/railties/lib/rails/command/base.rb +++ b/railties/lib/rails/command/base.rb @@ -64,7 +64,7 @@ module Rails end def printing_commands - namespace.sub(/^rails:/, "") + namespaced_commands end def executable @@ -135,6 +135,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 diff --git a/railties/lib/rails/commands/destroy/destroy_command.rb b/railties/lib/rails/commands/destroy/destroy_command.rb index 5b552b2070..c802910b5d 100644 --- a/railties/lib/rails/commands/destroy/destroy_command.rb +++ b/railties/lib/rails/commands/destroy/destroy_command.rb @@ -3,8 +3,10 @@ require "rails/generators" module Rails module Command class DestroyCommand < Base # :nodoc: - def help - Rails::Generators.help self.class.command_name + no_commands do + def help + Rails::Generators.help self.class.command_name + end end def perform(*) diff --git a/railties/lib/rails/commands/generate/generate_command.rb b/railties/lib/rails/commands/generate/generate_command.rb index 2718b453a8..9dd7ad1012 100644 --- a/railties/lib/rails/commands/generate/generate_command.rb +++ b/railties/lib/rails/commands/generate/generate_command.rb @@ -3,11 +3,13 @@ require "rails/generators" module Rails module Command class GenerateCommand < Base # :nodoc: - def help - require_application_and_environment! - load_generators + no_commands do + def help + require_application_and_environment! + load_generators - Rails::Generators.help self.class.command_name + Rails::Generators.help self.class.command_name + end end def perform(*) diff --git a/railties/lib/rails/commands/new/new_command.rb b/railties/lib/rails/commands/new/new_command.rb index 74d1fa5021..207dd5d995 100644 --- a/railties/lib/rails/commands/new/new_command.rb +++ b/railties/lib/rails/commands/new/new_command.rb @@ -1,8 +1,10 @@ module Rails module Command class NewCommand < Base # :nodoc: - def help - Rails::Command.invoke :application, [ "--help" ] + no_commands do + def help + Rails::Command.invoke :application, [ "--help" ] + end end def perform(*) diff --git a/railties/lib/rails/commands/runner/runner_command.rb b/railties/lib/rails/commands/runner/runner_command.rb index 4989a7837d..056ad980b9 100644 --- a/railties/lib/rails/commands/runner/runner_command.rb +++ b/railties/lib/rails/commands/runner/runner_command.rb @@ -5,9 +5,11 @@ module Rails default: Rails::Command.environment.dup, desc: "The environment for the runner to operate under (test/development/production)" - def help - super - puts self.class.desc + no_commands do + def help + super + puts self.class.desc + end end def self.banner(*) diff --git a/railties/lib/rails/commands/secrets/secrets_command.rb b/railties/lib/rails/commands/secrets/secrets_command.rb index b9ae5d8b3b..03a640bd65 100644 --- a/railties/lib/rails/commands/secrets/secrets_command.rb +++ b/railties/lib/rails/commands/secrets/secrets_command.rb @@ -4,10 +4,12 @@ require "rails/secrets" module Rails module Command class SecretsCommand < Rails::Command::Base # :nodoc: - def help - say "Usage:\n #{self.class.banner}" - say "" - say self.class.desc + no_commands do + def help + say "Usage:\n #{self.class.banner}" + say "" + say self.class.desc + end end def setup diff --git a/railties/lib/rails/commands/test/test_command.rb b/railties/lib/rails/commands/test/test_command.rb index 629fb5b425..65e16900ba 100644 --- a/railties/lib/rails/commands/test/test_command.rb +++ b/railties/lib/rails/commands/test/test_command.rb @@ -4,8 +4,10 @@ require "rails/test_unit/minitest_plugin" module Rails module Command class TestCommand < Base # :nodoc: - def help - perform # Hand over help printing to minitest. + no_commands do + def help + perform # Hand over help printing to minitest. + end end def perform(*) diff --git a/railties/test/command/base_test.rb b/railties/test/command/base_test.rb new file mode 100644 index 0000000000..ebfc4d0ba9 --- /dev/null +++ b/railties/test/command/base_test.rb @@ -0,0 +1,11 @@ +require "abstract_unit" +require "rails/command" +require "rails/commands/generate/generate_command" +require "rails/commands/secrets/secrets_command" + +class Rails::Command::BaseTest < ActiveSupport::TestCase + test "printing commands" do + assert_equal %w(generate), Rails::Command::GenerateCommand.printing_commands + assert_equal %w(secrets:setup secrets:edit), Rails::Command::SecretsCommand.printing_commands + end +end |