Sha256: 961ecdac9da289e45d28a71e885a0281b6caa7d89339d5ed6d08c000080ee1f5

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

require "pair/command_line"

module Pair
  class CommandLine
    class Host < self
      def run!
        parse!
        Pair::Session.host(options)
      end

      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
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pair-0.0.2 lib/pair/command_line/host.rb
pair-0.0.1 lib/pair/command_line/host.rb