bin/web-puppet in web-puppet-0.0.1 vs bin/web-puppet in web-puppet-0.1.0

- old
+ new

@@ -1,6 +1,43 @@ #!/usr/bin/env ruby require 'rack' +require 'optparse' require 'web-puppet' -Rack::Server.new(:app => WebPuppet::App.new, :Port => 9295, :daemonize => true).start +options = {:daemonize => true, :port => 9295, :config => false} + +optparse = OptionParser.new do |opts| + opts.banner = 'Usage: web-puppet [options] ...' + + opts.separator '' + opts.separator 'Configuration options:' + + opts.on( '--no-daemonize', "Don't daemonize the web server process") do |username| + options[:daemonize] = false + end + + opts.on( '-p', '--port PORT', 'The port to run web-puppet on') do |port| + options[:port] = port + end + + opts.on( '-c', '--config FILE', 'The file to load with configuration options') do |file| + options[:config] = file + end + + opts.on_tail('-h', '--help', 'Display this screen' ) do + puts opts + exit + end +end + +begin + optparse.parse! + WebPuppet::App.run!(options) +rescue OptionParser::InvalidArgument, OptionParser::InvalidOption, OptionParser::MissingArgument + puts $!.to_s + puts optparse + exit +rescue Errno::EACCES + puts $!.to_s + exit +end