nmhive.py: Add --host and --port options
authorW. Trevor King <wking@tremily.us>
Mon, 22 Sep 2014 12:58:57 +0000 (05:58 -0700)
committerW. Trevor King <wking@tremily.us>
Mon, 22 Sep 2014 14:08:51 +0000 (07:08 -0700)
Time to polish this up a bit now that it works in testing ;).

nmhive.py

index 06c2cd0c90889d0d876292969e703c5f7e54502f..4ee67470f4eb19b9b73b7c0c618a365f61b7e485 100755 (executable)
--- a/nmhive.py
+++ b/nmhive.py
@@ -1,5 +1,7 @@
 #!/usr/bin/env python
 
 #!/usr/bin/env python
 
+"""Serve a JSON API for getting/setting notmuch tags with nmbug commits."""
+
 import json
 import mailbox
 import os
 import json
 import mailbox
 import os
@@ -99,4 +101,16 @@ def gmane_message_id(group, article):
 
 
 if __name__ == '__main__':
 
 
 if __name__ == '__main__':
-    app.run(host='0.0.0.0')
+    import argparse
+
+    parser = argparse.ArgumentParser(description=__doc__)
+    parser.add_argument(
+        '-H', '--host', default='127.0.0.1',
+        help='The hostname to listen on.')
+    parser.add_argument(
+        '-p', '--port', type=int, default=5000,
+        help='The port to listen on.')
+
+    args = parser.parse_args()
+
+    app.run(host=args.host, port=args.port)