diff options
author | Irene Knapp <ireneista@gmail.com> | 2020-12-25 21:10:37 -0800 |
---|---|---|
committer | Irene Knapp <ireneista@gmail.com> | 2020-12-25 21:10:37 -0800 |
commit | efc68f54e3476de0bd209995c36043c26131b8df (patch) | |
tree | 676d6915d9daa336586aeb50fb46dcaf09622efb /src/main.rs | |
parent | f5ec40b8fbbe7d4409d94dafcbfcdd41b8a6202b (diff) |
refactor path parsing into a separate file, implement some Display traits, etc
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/src/main.rs b/src/main.rs index 2a5234f..36fb284 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use error::Error; +use crate::prelude::*; use std::io; use std::io::prelude::*; @@ -7,10 +7,10 @@ use std::io::prelude::*; lalrpop_mod!(pub commandline); pub mod error; pub mod path; +pub mod prelude; +pub mod result; -pub type Result<T> = std::result::Result<T, Error>; - pub enum Input { String(String), End, @@ -72,25 +72,9 @@ fn execute(input: &str) -> Result<()> { match invocation.as_slice() { ["paths", path_list, ..] => { - println!("{:?}", path_list); - match path::parser::PathListParser::new().parse(path_list) { - Ok(parsed_paths) => { - println!("paths '{:?}'", parsed_paths); - }, - Err(_) => { - match path::parser::PathListAllowingEmptyPathsParser::new() - .parse(path_list) - { - Ok(parsed) => { - println!("path list has empty component"); - println!("{:?}", parsed); - }, - Err(error) => { - println!("path list is okay, does not have empty component"); - println!("{:?}", error); - }, - } - }, + let paths = path::parse_path_list(path_list)?; + for path in &paths { + println!("{}", path); } }, _ => { |