Просмотр исходного кода

tau: allow modifying task description using EDITOR

dasman 2 лет назад
Родитель
Сommit
a6e05ad395
1 измененных файлов с 15 добавлено и 0 удалено
  1. 15 0
      bin/tau/tau-python/tau

+ 15 - 0
bin/tau/tau-python/tau

@@ -109,6 +109,13 @@ def prompt_comment_text():
         "# These lines will be removed"
         "# These lines will be removed"
     ])
     ])
 
 
+def prompt_description_edit(text):
+    return prompt_text([
+        f"{text}"
+        "# Edit the task description above this line",
+        "# These lines will be removed"
+    ])
+
 def set_task_attr(task, attr, val):
 def set_task_attr(task, attr, val):
     if attr not in known_attrs:
     if attr not in known_attrs:
         print(f"Error: invalid attribute: {attr} {val}")
         print(f"Error: invalid attribute: {attr} {val}")
@@ -389,6 +396,14 @@ async def modify_task(refid, args, server_name, port):
         elif arg.startswith("+") or arg.startswith("-"):
         elif arg.startswith("+") or arg.startswith("-"):
             changes["tags"] = []
             changes["tags"] = []
             changes["tags"].append(arg)
             changes["tags"].append(arg)
+        elif arg.lower() in ["desc", "description"]:
+            task = await api.fetch_task(refid, server_name, port)
+            desc = task["desc"]
+            new_desc = prompt_description_edit(desc).lstrip()
+            if desc == new_desc:
+                print("Abort due to unchanged description")
+                exit(-1)
+            changes["desc"] = new_desc
         elif ":" in arg:
         elif ":" in arg:
             attr, val = arg.split(":", 1)
             attr, val = arg.split(":", 1)
             if val.lower() == "none":
             if val.lower() == "none":