Mercurial > hg > bitsyblog
view bitsyblog/cli.py @ 131:2d944e8f24e9
py3
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Mon, 28 Dec 2020 19:22:23 +0000 |
parents | bc08a00a7d93 |
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()