view bitsyblog/cli.py @ 102:bc08a00a7d93

make user creation work again, wip
author Jeff Hammel <k0scist@gmail.com>
date Sun, 23 Feb 2014 16:50:06 -0800
parents dd4abe56edf7
children
line wrap: on
line source

#!/usr/bin/env python

"""
bitsyblog command line interface for user creation
"""

import argparse
import sys
from getpass import getpass
from user import FilespaceUsers

def main(args=sys.argv[1:]):

    # command line parser
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument('directory', help="base bitsyblog user directory")
    parser.add_argument('user', help="user name")
    parser.add_argument('-p', '--password', dest='password',
                        help="password for user")
    options = parser.parse_args(args)

    # read password if not given
    if not options.password:
        password = getpass("Enter password for {} : ".format(options.user))
        if password:
            options.password = password
        else:
            parser.error("No password given")

    # create userspace
    users = FilespaceUsers(options.directory)

    # create a user
    # TODO: password hashing

if __name__ == '__main__':
    main()