blob: d8d1dd63aec7819d9b46c2f57b1b55a8aeb287f2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
use snafu::{OptionExt, Snafu};
#[derive(Debug, Snafu)]
pub enum Error {
#[snafu(display("No command given"))]
CommandRequired,
}
pub type Result<T> = std::result::Result<T, Error>;
pub fn parse(line: &str) -> Result<(String, Vec<String>)> {
// TODO
let mut tokens = line
.split_whitespace()
.map(std::string::ToString::to_string);
let cmd = tokens.next().context(CommandRequired)?;
Ok((cmd, tokens.collect()))
}
|