26 lines
906 B
Python
26 lines
906 B
Python
import asyncio
|
|
|
|
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)
|