Class: Kontena::Plugin::Shell::BatchDoCommand
- Inherits:
-
SubCommand
- Object
- Command
- SubCommand
- Kontena::Plugin::Shell::BatchDoCommand
- Defined in:
- lib/kontena/plugin/shell/commands/batch_do.rb
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
Methods inherited from SubCommand
Methods inherited from Command
command, completions, description, #has_subcommands?, has_subcommands?, help, #initialize, #run, subcommands
Constructor Details
This class inherits a constructor from Kontena::Plugin::Shell::Command
Instance Method Details
#execute ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/kontena/plugin/shell/commands/batch_do.rb', line 12 def execute if args.size > 1 lines = args[1..-1].join(' ').split(/(?<!\\);/).map(&:strip) else lines = [] while buf = Readline.readline("#{Kontena.pastel.green('..')}#{Kontena.pastel.red('>')} ", true) buf.strip! break if buf == 'end' lines << buf unless buf.empty? end (lines.size + 1).times { Readline::HISTORY.pop } Readline::HISTORY.push "batch do #{lines.join('; ')}" end lines.each { |line| session.run_command(line) } end |