Class: Dip::Commands::Run
- Inherits:
-
Dip::Command
- Object
- Dip::Command
- Dip::Commands::Run
- Defined in:
- lib/dip/commands/run.rb
Instance Method Summary collapse
-
#execute ⇒ Object
TODO: Refactor rubocop:disable Metrics/AbcSize, Metrics/MethodLength.
-
#initialize(cmd, subcmd = nil, argv = []) ⇒ Run
constructor
A new instance of Run.
-
#prepare_compose_run_options(value) ⇒ Object
rubocop:enable Metrics/AbcSize, Metrics/MethodLength.
- #run_vars ⇒ Object
Methods inherited from Dip::Command
Constructor Details
Instance Method Details
#execute ⇒ Object
TODO: Refactor rubocop:disable Metrics/AbcSize, Metrics/MethodLength
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 |
# File 'lib/dip/commands/run.rb', line 19 def execute command = @config.fetch(@cmd) command[:subcommands] ||= {} if (subcommand = command[:subcommands].fetch(@subcmd, {})).any? subcommand[:command] ||= nil command.merge!(subcommand) elsif @subcmd @argv.unshift(@subcmd.to_s) end Dip.env.merge(command[:environment]) if command[:environment] compose_method = command.fetch(:compose_method, "run").to_s compose_argv = [] compose_argv.concat((command[:compose_run_options])) compose_argv.concat(run_vars) compose_argv << "--rm" if compose_method == "run" compose_argv << command.fetch(:service).to_s compose_argv += command[:command].to_s.shellsplit compose_argv.concat(@argv) Dip::Commands::Compose.new(compose_method, compose_argv).execute end |
#prepare_compose_run_options(value) ⇒ Object
rubocop:enable Metrics/AbcSize, Metrics/MethodLength
46 47 48 49 50 51 52 53 |
# File 'lib/dip/commands/run.rb', line 46 def (value) return [] unless value value.map do |o| o = o.start_with?("-") ? o : "--#{o}" o.shellsplit end.flatten end |