From e2badf6b537f8344edf9863c23742e4388c6bf6b Mon Sep 17 00:00:00 2001 From: crudo Date: Fri, 24 Mar 2017 15:54:08 +0100 Subject: [PATCH] Implement 'user set' command in cli.py. --- cli.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/cli.py b/cli.py index e2cd7e4..4d55ba1 100755 --- a/cli.py +++ b/cli.py @@ -63,6 +63,26 @@ def user_list(): print("No users found.") +@user.command('set') +@click.option('-p', '--password') +@click.argument('user_uid', type=click.INT) +def user_set(user_uid, password): + with db.get_session() as session: + user = session.query(User).get(user_uid) + + if not user: + print("No user found with id #{}.".format(user_uid)) + return + + if password: + user.password = password + + with db.get_session() as session: + session.add(user) + + print("User successfully edited.") + + @cli.group('event') def event(): pass