22 lines
951 B
Python
22 lines
951 B
Python
from textual.widgets import Static
|
|
import subprocess
|
|
|
|
from maildir_gtd.actions.next import action_next
|
|
def action_archive(app) -> None:
|
|
"""Archive the current email message."""
|
|
app.show_status(f"Archiving message {app.current_message_id}...")
|
|
try:
|
|
result = subprocess.run(
|
|
["himalaya", "message", "move", "Archives", str(app.current_message_id)],
|
|
capture_output=True,
|
|
text=True
|
|
)
|
|
if result.returncode == 0:
|
|
app.query_one("#main_content", Static).update(f"Message {app.current_message_id} archived.")
|
|
app.show_status(f"Message {app.current_message_id} archived.")
|
|
action_next(app) # Automatically show the next message
|
|
else:
|
|
app.query_one("#main_content", Static).update(f"Failed to archive message {app.current_message_id}.")
|
|
except Exception as e:
|
|
app.query_one("#main_content", Static).update(f"Error: {e}")
|