summary refs log tree commit diff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs87
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(())
 }
-