20 lines
475 B
Rust
20 lines
475 B
Rust
|
|
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> },
|
||
|
|
}
|
||
|
|
|
||
|
|
pub trait CliCommand {
|
||
|
|
type ExecErr: From<ParseError>;
|
||
|
|
|
||
|
|
fn parse_str(input: &str, rest: impl Iterator<Item = String>) -> Result<Self, ParseError>
|
||
|
|
where
|
||
|
|
Self: Sized;
|
||
|
|
}
|