aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-07-18 16:36:40 +0100
committerAkshay <[email protected]>2020-07-18 16:36:40 +0100
commit0b4af96a515d51c409c6dafef406542dee9da3d4 (patch)
tree21acafc98b48988d43627b8b8374ad02358f25d1 /src/main.rs
parent29d49dddaae57d59a2c99c376a632a0d9560dcfc (diff)
add smooth error handling
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs
index dc6081d..f83fc83 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -36,12 +36,18 @@ fn main() {
36 .get_matches(); 36 .get_matches();
37 if let Some(c) = matches.value_of("command") { 37 if let Some(c) = matches.value_of("command") {
38 let command = Command::from_string(c); 38 let command = Command::from_string(c);
39 if matches!(command, Command::TrackUp(_) | Command::TrackDown(_)) { 39 match command {
40 let mut app = App::load_state(); 40 Ok(Command::TrackUp(_)) | Ok(Command::TrackDown(_)) => {
41 app.parse_command(command); 41 let mut app = App::load_state();
42 app.save_state(); 42 app.parse_command(command);
43 } else { 43 app.save_state();
44 eprintln!("Invalid or unsupported command!"); 44 }
45 Err(e) => {
46 eprintln!("{}", e);
47 }
48 _ => eprintln!(
49 "Commands other than `track-up` and `track-down` are currently not supported!"
50 ),
45 } 51 }
46 } else { 52 } else {
47 let mut s = termion().unwrap(); 53 let mut s = termion().unwrap();