aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authoronielfa <[email protected]>2020-07-23 23:56:38 +0100
committeronielfa <[email protected]>2020-07-23 23:56:38 +0100
commit7e44bbff6d7f572f5f92b3a6b0f1d5e523379ba4 (patch)
treeb80e0883bbd1bd02fa11f790c80c471a77800602 /src/main.rs
parent242d58264df4842464e12c70297608bc0833d632 (diff)
parentd7c303dda4750a432478c94b3ed41bca1352d839 (diff)
Merge branch 'master' into feature/larger-names
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index d96119e..609738e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -12,7 +12,13 @@ use crate::command::{open_command_window, Command};
12use crate::utils::{load_configuration_file, AppConfig}; 12use crate::utils::{load_configuration_file, AppConfig};
13 13
14use clap::{App as ClapApp, Arg}; 14use clap::{App as ClapApp, Arg};
15
16#[cfg(any(target_os = "linux", target_os = "macos"))]
15use cursive::termion; 17use cursive::termion;
18
19#[cfg(target_os = "windows")]
20use cursive::crossterm;
21
16use cursive::views::{LinearLayout, NamedView}; 22use cursive::views::{LinearLayout, NamedView};
17use lazy_static::lazy_static; 23use lazy_static::lazy_static;
18 24
@@ -33,6 +39,14 @@ fn main() {
33 .value_name("CMD") 39 .value_name("CMD")
34 .help("run a dijo command"), 40 .help("run a dijo command"),
35 ) 41 )
42 .arg(
43 Arg::with_name("list")
44 .short("l")
45 .long("list")
46 .takes_value(false)
47 .help("list dijo habits")
48 .conflicts_with("command"),
49 )
36 .get_matches(); 50 .get_matches();
37 if let Some(c) = matches.value_of("command") { 51 if let Some(c) = matches.value_of("command") {
38 let command = Command::from_string(c); 52 let command = Command::from_string(c);
@@ -49,8 +63,17 @@ fn main() {
49 "Commands other than `track-up` and `track-down` are currently not supported!" 63 "Commands other than `track-up` and `track-down` are currently not supported!"
50 ), 64 ),
51 } 65 }
66 } else if matches.is_present("list") {
67 for h in App::load_state().list_habits() {
68 println!("{}", h);
69 }
52 } else { 70 } else {
71 #[cfg(target_os = "windows")]
72 let mut s = crossterm().unwrap();
73
74 #[cfg(any(target_os = "linux", target_os = "macos"))]
53 let mut s = termion().unwrap(); 75 let mut s = termion().unwrap();
76
54 let app = App::load_state(); 77 let app = App::load_state();
55 let layout = NamedView::new( 78 let layout = NamedView::new(
56 "Frame", 79 "Frame",