Commits

buge committed 6224dd6

Ongoing work on CLI.

  • Participants
  • Parent commits ff6e3da

Comments (0)

Files changed (5)

+#!/usr/bin/env python
+
+import sys
+import addrinfo.cli
+
+try:
+    addrinfo.cli.main(sys.argv)
+except KeyboardInterrupt:
+    sys.exit(1)
+

File addrinfo/cli.py

 """
 
 import argparse
+import sys
+
 from addrinfo import Address
 
 
-parser = argparse.ArgumentParser(
-    description="Provides information about MAC, EUI or IP addresses.")
-parser.add_argument('addresses', metavar='address', type=str, nargs='*',
-    help="a list of addresses to parse")
+def main(args = None):
+    if args is None:
+        args = sys.argv
+    parsed = parse_args(args)
+    for address in parsed.addresses:
+        a = Address.value_of(address)
+        print a
 
-args = parser.parse_args()
-for address in args.addresses:
-    a = Address.value_of(address)
-    print a
 
+def parse_args(args):
+    parser = argparse.ArgumentParser(
+        description="Provides information about MAC, EUI or IP addresses.")
+    parser.add_argument('addresses', metavar='address', type=str, nargs='*',
+        help="a list of addresses to parse")
 
+    return parser.parse_args(args[1:])
+
+
-API reference
-=============
+Library reference
+=================
 
 
 .. automodule:: addrinfo.addresses
-Application reference
-=====================
+Command line interface
+======================
 
 
+Synopsis
+--------
+
+::
+
+    addrinfo [-h] [address [address ...]]
+
+
+Description
+-----------
+
+
 # One entry per manual page. List of tuples
 # (source start file, name, description, authors, manual section).
 man_pages = [
-    ('cli', 'addrinfo', u'addrinfo Documentation', [u'Philipp Bunge'], 1)
+    ('cli', 'addrinfo',
+        u'provides information about MAC, EUI, IPv4 and IPv6 addresses',
+        [u'Philipp Bunge (buge@ox9.org)'], 1)
 ]