From 2c5a211c162c3e11bbd7ba61a14f8575d42efe50 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Wed, 15 Jan 2020 17:16:19 -0800 Subject: [PATCH] Add user-delete --- amanuensis/cli.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/amanuensis/cli.py b/amanuensis/cli.py index d702690..a18a614 100644 --- a/amanuensis/cli.py +++ b/amanuensis/cli.py @@ -151,6 +151,22 @@ def command_user_add(args): print(json.dumps(js, indent=2)) print("Username: {}\nUser ID: {}\nPassword: {}".format(args.username, new_user.uid, tmp_pw)) +@add_argument("--id", help="id of user to delete") +def command_user_delete(args): + import os + + import config + + user_path = config.prepend('user', args.uid) + if not os.path.isdir(user_path): + config.logger.error("No user with that id") + return -1 + else: + os.remove(user_path) + with config.json_rw('user', 'index.json') as j: + if args.uid in j: + del j[uid] + @no_argument def command_user_list(args): """Lists users"""