From 6963569a7d2d2acf88e75ff96c78b214127371a6 Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Thu, 14 Sep 2023 16:22:49 +0200 Subject: [PATCH] python tool: added rename feature --- cli/python/app.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cli/python/app.py b/cli/python/app.py index 09eef83..f3bda18 100644 --- a/cli/python/app.py +++ b/cli/python/app.py @@ -82,9 +82,12 @@ if len(sys.argv) > 1: while not (command == "quit" or command == "exit" or command == "q"): - delete = False + action = None if command[0:3] == "rm ": - delete = True + action = "delete" + command = command[3:] + elif command[0:3] == "mv ": + action = "rename" command = command[3:] try: @@ -93,10 +96,16 @@ while not (command == "quit" or command == "exit" or command == "q"): except: note = next((note for note in data if note["title"] == command), None) - if delete: + if action == "delete": if note and ask("delete '" + note["title"] + "'? "): data.remove(note) savedata() + elif action == "rename": + if note: + newname = input("new name: ") + if newname: + note["title"] = newname + savedata() elif note: editnote(note) else: