argv-todo 0.1.0

A Vim-style terminal todo manager with nested tasks, priorities, search, and local SQLite storage
use anyhow::{Result, bail};

#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub(crate) enum SortOrder {
    #[default]
    Priority,
    Manual,
}

impl SortOrder {
    pub(crate) fn label(self) -> &'static str {
        match self {
            Self::Priority => "priority",
            Self::Manual => "manual",
        }
    }

    pub(crate) fn next(self) -> Self {
        match self {
            Self::Priority => Self::Manual,
            Self::Manual => Self::Priority,
        }
    }

    pub(super) fn parse(value: &str) -> Result<Self> {
        match value {
            "priority" => Ok(Self::Priority),
            "manual" => Ok(Self::Manual),
            _ => bail!("sort_order must be priority or manual"),
        }
    }
}