Permalink
Browse files

Add server script with option switches

  • Loading branch information...
1 parent ec6aac8 commit 9a1fd46dd4b638257e01fbf226834bf9c60681d3 @indirect indirect committed Aug 2, 2010
Showing with 40 additions and 0 deletions.
  1. +40 −0 script/server
View
@@ -0,0 +1,40 @@
+#!/usr/bin/env ruby
+require "optparse"
+
+options = {}
+parser = OptionParser.new do |opts|
+ opts.banner = "Usage: server [options]"
+
+ opts.on("-p", "--port=PORT", "The port number to run on") do |portnum|
+ options[:portnum] = portnum
+ end
+
+ opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
+ options[:verbose] = v
+ end
+
+ opts.on("-q", "--quiet", "Run quietly") do |q|
+ options[:quiet] = q
+ end
+
+ opts.on_tail("-h", "--help", "Show this message") do
+ puts opts
+ exit(-1)
+ end
+end
+parser.parse!
+
+options[:portnum] ||= 8080
+
+if options[:verbose]
+ cmd = "run:noisy"
+elsif options[:quiet]
+ cmd = "run:silent"
+else
+ cmd = "run"
+end
+
+brcm_dir = File.expand_path("../..", __FILE__)
+Dir.chdir(brcm_dir)
+exec "rake #{cmd} PORT=#{options[:portnum]}"
+

0 comments on commit 9a1fd46

Please sign in to comment.