Class: Hotdog::Commands::Pssh
- Inherits:
-
Search
- Object
- BaseCommand
- Search
- Hotdog::Commands::Pssh
- Defined in:
- lib/hotdog/commands/pssh.rb
Constant Summary
Constants inherited from BaseCommand
BaseCommand::MASK_DATABASE, BaseCommand::MASK_QUERY, BaseCommand::PERSISTENT_DB
Instance Attribute Summary
Attributes inherited from Search
Attributes inherited from BaseCommand
#application, #logger, #options
Instance Method Summary collapse
Methods inherited from Search
#evaluate, #get_hosts_with_search_tags, #parse, #parse_options
Methods inherited from BaseCommand
#execute, #fixed_string?, #initialize, #parse_options, #reload
Constructor Details
This class inherits a constructor from Hotdog::Commands::BaseCommand
Instance Method Details
#define_options(optparse, options = {}) ⇒ Object
12 13 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 |
# File 'lib/hotdog/commands/pssh.rb', line 12 def (optparse, ={}) [:options] = [] [:user] = nil [:port] = nil [:identity_file] = nil [:forward_agent] = false [:max_parallelism] = nil [:color] = :auto optparse.on("-o SSH_OPTION", "Passes this string to ssh command through shell. This option may be given multiple times") do |option| [:options] += [option] end optparse.on("-i SSH_IDENTITY_FILE", "SSH identity file path") do |path| [:identity_file] = path end optparse.on("-A", "Enable agent forwarding", TrueClass) do |b| [:forward_agent] = b end optparse.on("-p PORT", "Port of the remote host", Integer) do |port| [:port] = port end optparse.on("-u SSH_USER", "SSH login user name") do |user| [:user] = user end optparse.on("-P PARALLELISM", "Max parallelism", Integer) do |n| [:max_parallelism] = n end optparse.on("-v", "--verbose", "Enable verbose ode") do |v| [:verbose] = v end optparse.on("--color=WHEN", "--colour=WHEN", "Enable colors") do |color| [:color] = color end end |
#run(args = [], options = {}) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/hotdog/commands/pssh.rb', line 47 def run(args=[], ={}) expression = args.join(" ").strip if expression.empty? # return everything if given expression is empty expression = "*" end begin node = parse(expression) rescue Parslet::ParseFailed => error STDERR.puts("syntax error: " + error.cause.ascii_tree) exit(1) end result0 = evaluate(node, self) if 0 < result0.length exec_command(result0, ) else STDERR.puts("no match found: #{expression}") exit(1) end end |