Files
dotfiles/mgr/src/cli.rs

24 lines
618 B
Rust
Raw Normal View History

use thiserror::Error;
#[derive(Error, Debug)]
pub enum ParseError {
#[error("no action given")]
MissingAction,
#[error("unknown action: {action}")]
UnknownAction { action: String },
#[error("unexpected input: {rest:?}")]
UnexpectedInput { rest: Vec<String> },
2025-10-10 12:41:04 +02:00
#[error("missing argument")]
MissingArgument,
#[error("error parsing argument: {message}")]
ArgumentParse { message: String },
}
pub trait CliCommand {
type ExecErr: From<ParseError>;
fn parse_str(input: &str, rest: impl Iterator<Item = String>) -> Result<Self, ParseError>
where
Self: Sized;
}