summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index f5f96b4..93880de 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -16,6 +16,23 @@ fn read_stdin() -> Result<String, Box<dyn Error>> {
fn main() -> Result<(), Box<dyn Error>> {
loop {
prompt()?;
- let _user_input = read_stdin()?;
+ let user_input = read_stdin()?;
+
+ if user_input.len() == 0 {
+ // control-d or end of input. Needs to be specially handled before
+ // the match because this is identical to whitespace after the trim.
+ break;
+ }
+
+ match user_input.trim() {
+ "" => {}
+ "exit" => {
+ break;
+ }
+ other_input => {
+ println!("Unknown input {}", other_input);
+ }
+ }
}
+ Ok(())
}