diff options
author | Irene Knapp <ireneista@gmail.com> | 2020-12-26 00:41:25 -0800 |
---|---|---|
committer | Irene Knapp <ireneista@gmail.com> | 2020-12-26 00:41:25 -0800 |
commit | 0448d438d13d1486fdbc678e54685e5c9b5a12b8 (patch) | |
tree | 8f886c884b8a82a94f965e61566040823c6b6f3b /src/main.rs | |
parent | da5655f12b0ea1a7d7fb2b56a8128d5962450c15 (diff) |
fix indentation to 2 spaces
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 87 |
1 files changed, 43 insertions, 44 deletions
diff --git a/src/main.rs b/src/main.rs index 36fb284..60c14ca 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,76 +12,75 @@ pub mod result; pub enum Input { - String(String), - End, + String(String), + End, } fn main() -> Result<()> { - std::process::exit(match repl() { - Ok(()) => 0, - Err(ref e) => { - eprintln!("{}", e); - 1 - } - }) + std::process::exit(match repl() { + Ok(()) => 0, + Err(ref e) => { + eprintln!("{}", e); + 1 + } + }) } fn repl() -> Result<()> { - println!("Hello, terminal!"); + println!("Hello, terminal!"); - loop { - prompt()?; + loop { + prompt()?; - let input = read()?; - match input { - Input::String(string) => execute(&string)?, - Input::End => break, - } + let input = read()?; + match input { + Input::String(string) => execute(&string)?, + Input::End => break, } + } - Ok(()) + Ok(()) } fn prompt() -> Result<()> { - print!("$ "); - io::stdout().flush()?; + print!("$ "); + io::stdout().flush()?; - Ok(()) + Ok(()) } fn read() -> Result<Input> { - let mut input = String::new(); - let n_bytes = io::stdin().read_line(&mut input)?; - - if n_bytes == 0 { - Ok(Input::End) - } else { - Ok(Input::String(input)) - } + let mut input = String::new(); + let n_bytes = io::stdin().read_line(&mut input)?; + + if n_bytes == 0 { + Ok(Input::End) + } else { + Ok(Input::String(input)) + } } fn execute(input: &str) -> Result<()> { - let invocation = commandline::InvocationParser::new().parse(input)?; - - println!("{}", input); - - match invocation.as_slice() { - ["paths", path_list, ..] => { - let paths = path::parse_path_list(path_list)?; - for path in &paths { - println!("{}", path); - } - }, - _ => { - println!("invocation '{:?}'", invocation); + let invocation = commandline::InvocationParser::new().parse(input)?; + + println!("{}", input); + + match invocation.as_slice() { + ["paths", path_list, ..] => { + let paths = path::parse_path_list(path_list)?; + for path in &paths { + println!("{}", path); } + }, + _ => { + println!("invocation '{:?}'", invocation); } + } - Ok(()) + Ok(()) } - |