use snafu::OptionExt as _; #[derive(Debug, snafu::Snafu)] pub enum Error { #[snafu(display("No command given"))] CommandRequired, } pub type Result = std::result::Result; pub fn parse(line: &str) -> Result<(String, Vec)> { // TODO let mut tokens = line .split_whitespace() .map(std::string::ToString::to_string); let cmd = tokens.next().context(CommandRequired)?; Ok((cmd, tokens.collect())) }