Commits

Jakub Wilk committed dc368c8

Document the password file format.

Comments (0)

Files changed (1)

 import os
 import subprocess as ipc
 import sys
+import textwrap
 
 import yaml
 
 def main():
     parser = argparse.ArgumentParser()
     subparsers = parser.add_subparsers()
-    c_show = subparsers.add_parser('show', help='show (some) passwords')
+    c_show = subparsers.add_parser('show',
+        help='show (some) passwords',
+        formatter_class=argparse.RawDescriptionHelpFormatter,
+        description=textwrap.dedent(do_show.__doc__),
+    )
     c_show.add_argument('--omit', action='store_true', help='omit passwords')
     c_show.add_argument('-x', '--x-clipboard', action='store_true', help='copy the password to clipboard')
     c_show.add_argument('keyword', metavar='KEYWORD')
     return options.action(options)
 
 def do_show(options):
+    '''
+    Read password file from standard input and output (some) passwords.
+    The password file should be GPG-encrypted YAML file using the following
+    structure:
+
+       - site: http://bogus.example.net/
+         user: j.r.hacker
+         password: PnlUbPkPtq
+
+       - site: http://random.example.org/
+         user: jrh
+         password: cUUZ4oUXFv
+
+    '''
     gpg = ipc.Popen(['gpg', '-q', '-d'], stdout=ipc.PIPE)
     for item in yaml.load(gpg.stdout):
         site = str(item['site'])