Sha256: 3b86584e454ce41d523c4eb2afcdb185e77e580f705693225f50facc8965c6c7
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
module Pair class Cli class Host < self def run! parse! with_valid_config do Pair::Session.host(options) end end def with_valid_config config = Pair.config unless config.api_token raise ApiTokenMissingError.new("api-token is required. try --help to understand how") end unless config.ssh_on? raise EnableSSHError.new("ssh is not enabled, turn on ssh daemon to continue") end yield end def parse! opts = parse do |opts| opts.banner = "Usage: #{$0.split("/").last} 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 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pair-0.0.4 | lib/pair/cli/host.rb |