From 54ee15a203d7463534c2188141c6fb0090c9dc44 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Sun, 26 Feb 2017 21:05:13 +0900 Subject: Show correct commands in help Currently rails' help shows only namespace. However, the secrets command needs to specify command. Therefore, I fixed the command to display in help. --- railties/lib/rails/command/base.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'railties/lib/rails/command') 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 -- cgit v1.2.3 From 40bdbce191ad90dfea43dad51fac5c4726b89392 Mon Sep 17 00:00:00 2001 From: bogdanvlviv Date: Mon, 15 May 2017 14:17:28 +0000 Subject: Define path with __dir__ ".. with __dir__ we can restore order in the Universe." - by @fxn Related to 5b8738c2df003a96f0e490c43559747618d10f5f --- railties/lib/rails/command/actions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib/rails/command') diff --git a/railties/lib/rails/command/actions.rb b/railties/lib/rails/command/actions.rb index 8fda1c87c6..a00e58997c 100644 --- a/railties/lib/rails/command/actions.rb +++ b/railties/lib/rails/command/actions.rb @@ -5,7 +5,7 @@ module Rails # This allows us to run `rails server` from other directories, but still get # the main config.ru and properly set the tmp directory. def set_application_directory! - Dir.chdir(File.expand_path("../../", APP_PATH)) unless File.exist?(File.expand_path("config.ru")) + Dir.chdir(File.expand_path("../..", APP_PATH)) unless File.exist?(File.expand_path("config.ru")) end def require_application_and_environment! -- cgit v1.2.3 From 618268b4b9382f4bcf004a945fe2d85c0bd03e32 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Fri, 30 Jun 2017 13:55:31 +0900 Subject: [Railties] require => require_relative --- railties/lib/rails/command/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib/rails/command') diff --git a/railties/lib/rails/command/base.rb b/railties/lib/rails/command/base.rb index 4f074df473..cd0720be4e 100644 --- a/railties/lib/rails/command/base.rb +++ b/railties/lib/rails/command/base.rb @@ -4,7 +4,7 @@ require "erb" require "active_support/core_ext/string/filters" require "active_support/core_ext/string/inflections" -require "rails/command/actions" +require_relative "actions" module Rails module Command -- cgit v1.2.3 From 48b249927375465a7102acc71c2dfb8d49af8309 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Fri, 9 Jun 2017 00:15:41 +0200 Subject: Deprecate environment as an argument for dbconsole and console People should rather rely on the `-e` or `--environment` options to specify in which environment they want to work. This will allow us to specify the connection to pick as a regular argument in the future. --- railties/lib/rails/command/environment_argument.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'railties/lib/rails/command') diff --git a/railties/lib/rails/command/environment_argument.rb b/railties/lib/rails/command/environment_argument.rb index 05eac34155..3469463db5 100644 --- a/railties/lib/rails/command/environment_argument.rb +++ b/railties/lib/rails/command/environment_argument.rb @@ -13,6 +13,12 @@ module Rails def extract_environment_option_from_argument if environment self.options = options.merge(environment: acceptable_environment(environment)) + + ActiveSupport::Deprecation.warn "Passing the environment's name as a " \ + "regular argument is deprecated and " \ + "will be removed in the next Rails " \ + "version. Please, use the -e option " \ + "instead." elsif !options[:environment] self.options = options.merge(environment: Rails::Command.environment) end -- cgit v1.2.3 From 3777701f1380f3814bd5313b225586dec64d4104 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Sun, 16 Jul 2017 14:54:04 +0200 Subject: Properly expand the environment's name Running the `console` and `dbconsole` commands with a regular argument as the environment's name automatically expand it to match an existing environment (e.g. dev for development). This feature wasn't available using the `--environment` (a.k.a `-e`) option. --- railties/lib/rails/command/environment_argument.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'railties/lib/rails/command') diff --git a/railties/lib/rails/command/environment_argument.rb b/railties/lib/rails/command/environment_argument.rb index 3469463db5..9582509840 100644 --- a/railties/lib/rails/command/environment_argument.rb +++ b/railties/lib/rails/command/environment_argument.rb @@ -7,6 +7,9 @@ module Rails included do argument :environment, optional: true, banner: "environment" + + class_option :environment, aliases: "-e", type: :string, + desc: "Specifies the environment to run this console under (test/development/production)." end private @@ -19,7 +22,9 @@ module Rails "will be removed in the next Rails " \ "version. Please, use the -e option " \ "instead." - elsif !options[:environment] + elsif options[:environment] + self.options = options.merge(environment: acceptable_environment(options[:environment])) + else self.options = options.merge(environment: Rails::Command.environment) end end -- cgit v1.2.3