38 lines
761 B
Python
38 lines
761 B
Python
"""Accountant runner."""
|
|
|
|
# vim: set tw=80 ts=4 sw=4 sts=4:
|
|
|
|
from os import path, getcwd
|
|
|
|
import click
|
|
|
|
from . import create_app
|
|
|
|
from .models import db
|
|
from .models.users import User
|
|
|
|
|
|
config_path = path.join(getcwd(), 'config.cfg') # pylint: disable=invalid-name
|
|
app = create_app(config_path) # pylint: disable=invalid-name
|
|
|
|
|
|
# Define commands to handle users.
|
|
@app.cli.group()
|
|
def users():
|
|
""" User management. """
|
|
pass
|
|
|
|
|
|
@users.command()
|
|
@click.argument('email')
|
|
@click.argument('password')
|
|
def add(email, password):
|
|
""" Add a new user. """
|
|
user = User()
|
|
user.email = email
|
|
user.password = User.hash_password(password)
|
|
|
|
db.session.add(user) # pylint: disable=no-member
|
|
|
|
click.echo("User '%s' successfully added." % email)
|