Sha256: a0a7e1f356ff9a7fc88475551a49151afe72c5dce5a5bf000a01c1ab9f97a9b0
Contents?: true
Size: 1.47 KB
Versions: 2
Compression:
Stored size: 1.47 KB
Contents
module Shere; end module Shere::Runner module_function def options @options ||= [['-p, --port PORT', 'Which port Nginx should listen on (default 4331)'], ['-o, --host HOST', 'Which host Nginx should use (default _)' ], ['-u, --user USER', 'Which user Nginx should use' \ ' (if having root privilege)'], [' --help' , 'Print this message' ], ['-v, --version' , 'Print the version' ]] end def run argv=ARGV.dup opts = parse(argv) require 'shere' Shere.run(opts) end def parse argv opts = {} until argv.empty? case arg = argv.shift when /^-p=?(.+)?/, /^--port=?(.+)?/ opts[:port] = $1 || argv.shift when /^-o=?(.+)?/, /^--host=?(.+)?/ opts[:host] = $1 || argv.shift when /^-u=?(.+)?/, /^--user=?(.+)?/ opts[:user] = $1 || argv.shift when '-h', '--help' puts(help) exit when '-v', '--version' require 'shere/version' puts(Shere::VERSION) exit else opts[:root] = arg end end opts end def help maxn = options.transpose.first.map(&:size).max maxd = options.transpose.last .map(&:size).max "Usage: shere ROOT\n" + options.map{ |(name, desc)| if desc.empty? name else sprintf(" %-*s %-*s", maxn, name, maxd, desc) end }.join("\n") end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
shere-0.9.2 | lib/shere/runner.rb |
shere-0.9.1 | lib/shere/runner.rb |