From 0448d438d13d1486fdbc678e54685e5c9b5a12b8 Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Sat, 26 Dec 2020 00:41:25 -0800 Subject: fix indentation to 2 spaces --- src/main.rs | 87 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 43 insertions(+), 44 deletions(-) (limited to 'src/main.rs') 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 { - 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(()) } - -- cgit 1.4.1