about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-06-26 08:48:48 +0000
committerEric Wong <normalperson@yhbt.net>2010-06-26 08:48:48 +0000
commitc99e192863f22376abc1c8e131639320819de11e (patch)
tree5a6a647ecc64975e8cdaa03c5a1625d45d9a48ce
parentddbc6236c1cbda79ff0606166137fa2c37b7e2b0 (diff)
downloadlocal-openid-c99e192863f22376abc1c8e131639320819de11e.tar.gz
command-line option parsing v0.2.0
-rw-r--r--README15
-rwxr-xr-xbin/local-openid18
2 files changed, 29 insertions, 4 deletions
diff --git a/README b/README
index b8def5e..9999479 100644
--- a/README
+++ b/README
@@ -44,9 +44,18 @@ server.  To be useful, it also depends on having a user account on a
 machine with a publically-accessible IP and DNS name to use as your
 OpenID identity.
 
-"local-openid" should be installed in your $PATH by RubyGems.
-It is a Sinatra application and takes all the usual command-line
-arguments.  Run "local-openid -h" for help.
+== Running
+
+"local-openid" should be installed in your $PATH by RubyGems or
+setup.rb.  It is a Sinatra application and takes the usual
+command-line arguments.  It binds on all addresses (0.0.0.0) and port
+4567 by default, using the standard WEBrick web server.
+
+You may specify a different port with the *-p* switch and address with
+the *-o* switch.  The following command will start local-openid on port
+3000 bound to localhost (useful if behind a reverse proxy like nginx).
+
+  local-openid -o 127.0.0.1 -p 3000
 
 == Hacking
 
diff --git a/bin/local-openid b/bin/local-openid
index 7fc6b33..4b8f315 100755
--- a/bin/local-openid
+++ b/bin/local-openid
@@ -1,3 +1,19 @@
 #!/usr/bin/env ruby
 require 'local_openid'
-LocalOpenID.run!
+require 'optparse'
+require 'socket'
+BasicSocket.do_not_reverse_lookup = true
+opts = {
+  :server => 'webrick', # webrick is standard, and plenty fast enough
+}
+OptionParser.new { |op|
+  op.on('-s <mongrel|thin|webrick>') { |v| opts[:server] = v }
+  op.on('-p port')   { |val| opts[:port] = val.to_i }
+  op.on('-o addr')   { |val| opts[:bind] = val }
+  op.on('-h', '--help', 'Show this message') do
+    puts op.to_s
+    exit
+  end
+}.parse!(ARGV)
+
+LocalOpenID.run!(opts)