Sha256: 85d463b8d07336cc4ec24af2937fa3c159ecae78a832795d3c5a2ad6e81c7a59

Contents?: true

Size: 706 Bytes

Versions: 1

Compression:

Stored size: 706 Bytes

Contents

require 'optparse'

module SnowmanIO
  # Parse command line.
  class Options
    AVAILABLE_COMMANDS = %w[server]

    def parse!(args)
      options = default_options

      opt_parser = OptionParser.new do |opts|
        opts.banner = "Usage: snowman [options]"

        opts.separator ""
        opts.separator "Options:"
        opts.on("-p", "--port PORT", "use PORT (default: 4567)") do |port|
          options[:port] = port.to_i
        end

        opts.on("-h", "--help", "show this message") do
          puts opts
          exit
        end
      end

      opt_parser.parse!(args)
      options
    end

    private

    def default_options
      {
        port: 4567
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
snowman-io-0.0.4 lib/snowman-io/options.rb