diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2016-09-26 20:28:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-26 20:28:40 +0200 |
commit | c994a893c18c0456fd2a30efe4debfc2b18e2508 (patch) | |
tree | 0253b1343a1760dc4701f7d2ee2ff8cdd1d1b290 /railties/lib/rails/commands/common_commands_tasks.rb | |
parent | a6da7938017647dd6e19e23d3d47126cb7a3e1fe (diff) | |
parent | c0c73738bd04c86fbcf6d22c961fec0d33aa2bf6 (diff) | |
download | rails-c994a893c18c0456fd2a30efe4debfc2b18e2508.tar.gz rails-c994a893c18c0456fd2a30efe4debfc2b18e2508.tar.bz2 rails-c994a893c18c0456fd2a30efe4debfc2b18e2508.zip |
Merge pull request #26414 from rails/rails-commands
Initial Rails Commands Infrastructure
Diffstat (limited to 'railties/lib/rails/commands/common_commands_tasks.rb')
-rw-r--r-- | railties/lib/rails/commands/common_commands_tasks.rb | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/railties/lib/rails/commands/common_commands_tasks.rb b/railties/lib/rails/commands/common_commands_tasks.rb deleted file mode 100644 index c1484d7ae2..0000000000 --- a/railties/lib/rails/commands/common_commands_tasks.rb +++ /dev/null @@ -1,68 +0,0 @@ -module Rails - module CommonCommandsTasks # :nodoc: - def run_command!(command) - command = parse_command(command) - - if command_whitelist.include?(command) - send(command) - else - run_rake_task(command) - end - end - - def generate - generate_or_destroy(:generate) - end - - def destroy - generate_or_destroy(:destroy) - end - - def test - require_command!("test") - end - - def version - argv.unshift "--version" - require_command!("application") - end - - def help - write_help_message - write_commands(commands) - end - - private - - def generate_or_destroy(command) - require "rails/generators" - require_application_and_environment! - load_generators - require_command!(command) - end - - def require_command!(command) - require "rails/commands/#{command}" - end - - def write_help_message - puts help_message - end - - def write_commands(commands) - width = commands.map { |name, _| name.size }.max || 10 - commands.each { |command| printf(" %-#{width}s %s\n", *command) } - end - - def parse_command(command) - case command - when "--version", "-v" - "version" - when "--help", "-h" - "help" - else - command - end - end - end -end |