Class: Pssh::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/pssh/cli.rb

Constant Summary collapse

<<-BANNER
Usage: pssh [options]

Description:

  Remote pair programming made easy by allowing access via a web
  browser.  Supports HTTP Basic Auth to handle users, and can be
  combined with tmux, screen, or just a plain shell.

BANNER

Class Method Summary collapse

Class Method Details

.parse_options(args) ⇒ Object



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
46
# File 'lib/pssh/cli.rb', line 15

def self.parse_options(args)
  options = {}

  @opts = OptionParser.new do |opts|
    opts.banner = BANNER.gsub(/^ {4}/, '')

    opts.separator ''
    opts.separator 'Options:'

    opts.on('--readonly', 'Only allow viewing the session, not writing.') do
      options[:io_mode] = 'r'
    end

    opts.on('-p PORT', '--port PORT', Integer, 'Set the port that Pssh will run on') do |port|
      options[:port] = port.to_i
    end

    opts.on('-s NAME', '--socket NAME', String, 'Set the socket that will be used for connecting (socket-name)') do |socket|
      options[:socket_path] = socket
    end

    opts.on( '-h', '--help', 'Display this help.' ) do
      puts opts
      exit
    end

  end

  @opts.parse!(args)

  options
end

.run(args) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/pssh/cli.rb', line 48

def self.run(args)
  opts = parse_options(args)
  Pssh.configure do |pssh|
    opts.each do |k,v|
      pssh.send :"#{k}=", v
    end
  end
  Pssh::Client.start
end