refactor email viewer app
This commit is contained in:
22
maildir_gtd/actions/task.py
Normal file
22
maildir_gtd/actions/task.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import subprocess
|
||||
from maildir_gtd.screens.CreateTask import CreateTaskScreen
|
||||
|
||||
|
||||
def action_create_task(app) -> None:
|
||||
"""Show the input modal for creating a task."""
|
||||
def check_task(task_args: str) -> bool:
|
||||
try:
|
||||
result = subprocess.run(
|
||||
["task", "add"] + task_args.split(" "),
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
if result.returncode == 0:
|
||||
app.show_status("Task created successfully.")
|
||||
else:
|
||||
app.show_status(f"Failed to create task: {result.stderr}")
|
||||
except Exception as e:
|
||||
app.show_status(f"Error: {e}", severity="error")
|
||||
return True
|
||||
return False
|
||||
app.push_screen(CreateTaskScreen(), check_task)
|
||||
Reference in New Issue
Block a user