Class: Bow::Commands::Exec

Inherits:
Bow::Command show all
Defined in:
lib/bow/commands/exec.rb

Instance Attribute Summary

Attributes inherited from Bow::Command

#app

Instance Method Summary collapse

Methods inherited from Bow::Command

#command_name, command_name, find, inherited, #initialize, #targets

Constructor Details

This class inherits a constructor from Bow::Command

Instance Method Details

#descriptionObject



6
7
8
# File 'lib/bow/commands/exec.rb', line 6

def description
  'Exec command on remote hosts.'
end

#runObject

Raises:

  • (ArgumentError)


14
15
16
17
18
19
20
21
22
23
# File 'lib/bow/commands/exec.rb', line 14

def run
  raise ArgumentError, 'Command required!' unless @argv && !@argv&.empty?
  cmd = @argv.shift
  ThreadPool.new do |t|
    t.from_enumerable targets do |host|
      result = app.ssh_helper(host).execute(cmd)
      ResponseFormatter.pretty_print(host, result)
    end
  end
end

#usageObject



10
11
12
# File 'lib/bow/commands/exec.rb', line 10

def usage
  "bow #{command_name} command [args] [options]"
end