[csw-devel] SF.net SVN: opencsw:[404] catalog_signatures/catalog_gpg

bdwalton at users.sourceforge.net bdwalton at users.sourceforge.net
Thu Jul 21 04:59:48 CEST 2011


Revision: 404
          http://opencsw.svn.sourceforge.net/opencsw/?rev=404&view=rev
Author:   bdwalton
Date:     2011-07-21 02:59:48 +0000 (Thu, 21 Jul 2011)

Log Message:
-----------
add option handling machinery to allow overriding defaults

Signed-off-by: Ben Walton <bwalton at artsci.utoronto.ca>

Modified Paths:
--------------
    catalog_signatures/catalog_gpg

Modified: catalog_signatures/catalog_gpg
===================================================================
--- catalog_signatures/catalog_gpg	2011-07-21 02:59:30 UTC (rev 403)
+++ catalog_signatures/catalog_gpg	2011-07-21 02:59:48 UTC (rev 404)
@@ -21,6 +21,23 @@
 opts.port = 9981
 opts.mirror_path = File.dirname($0)
 
+OptionParser.new do |o|
+  o.banner = "Usage: #{File.basename($0)} [options]"
+  o.separator ''
+
+  o.on('-b', '--mirror-path PATH', "Use PATH as the root of the mirror\n" +
+       "\t\t\t\t     tree where catalogs can be found.") do |p|
+    if File.directory?(p)
+      opts.mirror_path = p
+    else
+      $stderr.puts "Invalid mirror path: #{p}"
+      exit 1
+    end
+  end
+  o.on('-h', '--help', 'Display help output.') { puts o; exit 0 }
+  o.on('-p', '--port PORT', "Use a port other than #{opts.port}") { |p| opts.port = p.to_i }
+end.parse!
+
 server = WEBrick::HTTPServer.new({ :Port => opts.port })
 server.mount "/clearsign", GPGDaemon, opts.mirror_path
 server.mount "/detachsign", GPGDaemon, opts.mirror_path


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


More information about the devel mailing list