Replace common functionality with rust implementation
This commit is contained in:
19
mgr/src/cli.rs
Normal file
19
mgr/src/cli.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user