Files
luk/maildir_gtd/actions/task.py
2025-05-04 19:53:27 -06:00

28 lines
949 B
Python

import asyncio
import subprocess
from textual import work
from maildir_gtd.screens.CreateTask import CreateTaskScreen
def action_create_task(app) -> None:
"""Show the input modal for creating a task."""
async def check_task(task_args: str) -> bool:
try:
result = await asyncio.create_subprocess_shell(
f"task add {task_args}",
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE
)
stdout, stderr = await result.communicate()
if result.returncode == 0:
app.show_status(f"Task created: {stdout.decode()}")
else:
app.show_status(f"Failed to create task: {stderr.decode()}", severity="error")
except Exception as e:
app.show_status(f"Error: {e}", severity="error")
return True
return False
app.push_screen(CreateTaskScreen(), check_task)