Class: Magpie::Server::Options
- Inherits:
-
Object
- Object
- Magpie::Server::Options
- Defined in:
- lib/magpie/server.rb
Instance Method Summary (collapse)
Instance Method Details
- (Object) parse!(args)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/magpie/server.rb', line 8 def parse!(args) = {} opt_parser = OptionParser.new("", 24, ' ') do |opts| opts. = "Usage: mag [rack options] [mag config]" opts.separator "" opts.separator "Rack options:" opts.on("-s", "--server SERVER", "serve using SERVER (webrick/mongrel)") { |s| [:server] = s } opts.on("-o", "--host HOST", "listen on HOST (default: 0.0.0.0)") { |host| [:Host] = host } opts.on("-p", "--port PORT", "use PORT (default: 9292)") { |port| [:Port] = port } opts.on("-D", "--daemonize", "run daemonized in the background") { |d| [:daemonize] = d ? true : false } opts.on("-P", "--pid FILE", "file to store PID (default: rack.pid)") { |f| [:pid] = f } opts.on("-M", "--mode MODE", "开启magpie模式选项(snake, bird 默认模式是snake)"){ |mode| [:mode] = mode } opts.on("-L", "--log logfile", "指定日志文件"){ |logfile| [:log] = logfile } opts.separator "" opts.separator "Common options:" opts.on_tail("-h", "--help", "Show this message") do puts opts exit end opts.on_tail("--version", "Show version") do puts "Magpie #{Magpie.version}" exit end end opt_parser.parse! args [:yml] = args.last if args.last end |