Class: Pair::CommandLine::Host

Inherits:
Pair::CommandLine show all
Defined in:
lib/pair/command_line/host.rb

Instance Attribute Summary

Attributes inherited from Pair::CommandLine

#arguments, #options

Instance Method Summary collapse

Methods inherited from Pair::CommandLine

#initialize, run!

Constructor Details

This class inherits a constructor from Pair::CommandLine

Instance Method Details

#parse!Object



11
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
# File 'lib/pair/command_line/host.rb', line 11

def parse!
  opts = parse do |opts|
    opts.banner = "Usage: #{$0} host [-s SESSION_NAME] [-v PAIR[,PAIR[,...]] [-p PAIR[,PAIR[,...]]" +
                  "\n\n" +
                  "At least one PAIR (of any type must be defined). A PAIR takes the form of a Github username." +
                  "\n\n"+
                  "Options:"

    opts.on("-s", "--session-name=SESSION_NAME", "Automatically generated by server if not provided.") do |session_name|
      options[:name] = session_name
    end

    opts.on("-v", "--viewers=PAIRS", Array) do |pairs|
      options[:viewers] = pairs
    end

    opts.on("-p", "--participants=PAIRS", Array) do |pairs|
      options[:participants] = pairs
    end

    opts.on_tail("-h", "--help", "Display this text") do
      puts opts
      exit
    end
  end

  if options[:viewers].to_a.empty? && options[:participants].to_a.empty?
    $stderr.puts "ERROR: At least one PAIR is required...\n\n"
    abort(opts.inspect)
  end
end

#run!Object



6
7
8
9
# File 'lib/pair/command_line/host.rb', line 6

def run!
  parse!
  Pair::Session.host(options)
end