Class: Harbor::CLI::Rails
- Inherits:
-
Object
- Object
- Harbor::CLI::Rails
- Defined in:
- lib/harbor/cli/rails.rb
Constant Summary collapse
- INTERACTIVE_COMMANDS =
%w[console dbconsole].freeze
Instance Method Summary collapse
-
#initialize(options, config) ⇒ Rails
constructor
A new instance of Rails.
- #run(project_name, subcommand, extra_args = []) ⇒ Object
Constructor Details
Instance Method Details
#run(project_name, subcommand, extra_args = []) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/harbor/cli/rails.rb', line 14 def run(project_name, subcommand, extra_args = []) if INTERACTIVE_COMMANDS.include?(subcommand) # Interactive console needs a real TTY; exec replaces the CLI # process so stdin/stdout flow straight through to kamal. Can't # route through the kernel (it returns a string, not a stream). run_interactive(project_name, subcommand) return end if subcommand == "runner" raise Harbor::Error, "runner requires a script argument" if extra_args.empty? output = @tools.call( "harbor_runner", { "project" => project_name, "script" => extra_args.join(" "), "destination" => @options["destination"] }, actor: cli_actor, origin: :cli ) else output = @tools.call( "harbor_rails", { "project" => project_name, "command" => subcommand, "args" => extra_args.empty? ? nil : extra_args.join(" "), "destination" => @options["destination"] }, actor: cli_actor, origin: :cli ) end $stdout.puts output rescue Harbor::Error => e $stderr.puts "#{e.class.name.split('::').last}: #{e.}" exit 1 end |