Class: PolySSH::Cli
- Inherits:
-
Object
- Object
- PolySSH::Cli
- Defined in:
- lib/polyssh/cli.rb
Instance Attribute Summary collapse
-
#chain ⇒ Object
readonly
Returns the value of attribute chain.
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
Class Method Summary collapse
Instance Method Summary collapse
- #build_commands(chain) ⇒ Object
-
#initialize ⇒ Cli
constructor
A new instance of Cli.
- #parse_cmdline(args) ⇒ Object
- #run_commands(commands) ⇒ Object
Constructor Details
Instance Attribute Details
#chain ⇒ Object (readonly)
Returns the value of attribute chain.
9 10 11 |
# File 'lib/polyssh/cli.rb', line 9 def chain @chain end |
#commands ⇒ Object (readonly)
Returns the value of attribute commands.
9 10 11 |
# File 'lib/polyssh/cli.rb', line 9 def commands @commands end |
Class Method Details
.start(args) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/polyssh/cli.rb', line 11 def self.start args app = self.new app.parse_cmdline args puts "Building SSH hops...".yellow app.build_commands app.chain #app.commands.each{|x| puts x } puts "Running SSH hops...".yellow app.run_commands app.commands end |
Instance Method Details
#build_commands(chain) ⇒ Object
43 44 45 46 |
# File 'lib/polyssh/cli.rb', line 43 def build_commands chain @commands = chain.accept(CommandBuilder.new) return @commands end |
#parse_cmdline(args) ⇒ Object
29 30 31 32 |
# File 'lib/polyssh/cli.rb', line 29 def parse_cmdline args args _parse_cmdline_hops args end |
#run_commands(commands) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/polyssh/cli.rb', line 34 def run_commands commands @commands[0..-2].each do |baseport,cmd| fork { exec cmd + " >/dev/null 2>&1 " } _wait_active_port baseport end _baseport, cmd = @commands.last system cmd end |