Sha256: 8967627026b818d2fab17916e29969f316c5e15c312b967073c8714ce5355eac

Contents?: true

Size: 1.17 KB

Versions: 5

Compression:

Stored size: 1.17 KB

Contents

require 'optparse'

module Reloadlive
  help = <<HELP
Reloadlive is command line tool to easily preview your github-markup files

Basic Command Line Usage:
  reloadlive [OPTIONS] [DIRS]
HELP
  @@options = { 'port' => 4567, 'host' => '0.0.0.0', 'static' => Dir.pwd }
  options_parser = OptionParser.new do |opts|
    opts.banner = help

    opts.on("--port [PORT]", "Bind port (default 4567).") do |port|
      @@options['port'] = port.to_i
    end

    opts.on("--host [HOST]", "Hostname or IP address to listen on (default 0.0.0.0).") do |host|
      @@options['bind'] = host
    end

    opts.on("--static [PATH]", "Specify the static path.") do |path|
      @@options['static'] = path
    end

    opts.on("--version", "Display current version.") do
      puts "Reloadlive " + Reloadlive::VERSION
      exit 0
    end
  end

  begin
    options_parser.parse!
  rescue OptionParser::InvalidOption
    puts "reloadlive: #{$!.message}"
    puts "reloadlive: try 'reloadlive --help' for more information"
    exit
  end


  if ARGV.empty?
    @@options['watch'] = [Dir.pwd]
  else
    @@options['watch'] = ARGV.dup
  end

  def options
    @@options
  end

  def self.options
    @@options
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
reloadlive-1.0.4 lib/reloadlive/options.rb
reloadlive-1.0.3 lib/reloadlive/options.rb
reloadlive-1.0.2 lib/reloadlive/options.rb
reloadlive-1.0.1 lib/reloadlive/options.rb
reloadlive-1.0.0 lib/reloadlive/options.rb