aboutsummaryrefslogtreecommitdiffstats
path: root/src/parser.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser.rs')
-rw-r--r--src/parser.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/parser.rs b/src/parser.rs
new file mode 100644
index 0000000..cc86020
--- /dev/null
+++ b/src/parser.rs
@@ -0,0 +1,14 @@
+#[derive(Debug)]
+pub enum Error {
+ CommandRequired,
+}
+
+pub fn parse(line: &str) -> Result<(String, Vec<String>), Error> {
+ // TODO
+ let mut tokens = line.split_whitespace().map(|s| s.to_string());
+ if let Some(cmd) = tokens.next() {
+ Ok((cmd, tokens.collect()))
+ } else {
+ Err(Error::CommandRequired)
+ }
+}