diff options
author | Akshay <[email protected]> | 2020-07-23 17:53:59 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2020-07-23 17:53:59 +0100 |
commit | 91cb3ebf5b3af666b13f4821ff25f219fdccd7b9 (patch) | |
tree | c91d6cffd4d215b325e81bedfdcfdfdcea76a537 /src/main.rs | |
parent | 02bba52346d948e90fbc1b351486f0f1307c243d (diff) | |
parent | d1d1aeb3d5aaa75f262467c5e683e76ce7a844ab (diff) |
Merge branch 'feature/windows' of https://github.com/filalex77/dijo into feature/windows
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index fb16aaa..dec3156 100644 --- a/src/main.rs +++ b/src/main.rs | |||
@@ -12,7 +12,13 @@ use crate::command::{open_command_window, Command}; | |||
12 | use crate::utils::{load_configuration_file, AppConfig}; | 12 | use crate::utils::{load_configuration_file, AppConfig}; |
13 | 13 | ||
14 | use clap::{App as ClapApp, Arg}; | 14 | use clap::{App as ClapApp, Arg}; |
15 | |||
16 | #[cfg(target_os = "linux")] | ||
17 | use cursive::termion; | ||
18 | |||
19 | #[cfg(target_os = "windows")] | ||
15 | use cursive::crossterm; | 20 | use cursive::crossterm; |
21 | |||
16 | use cursive::views::{LinearLayout, NamedView}; | 22 | use cursive::views::{LinearLayout, NamedView}; |
17 | use lazy_static::lazy_static; | 23 | use 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")] | ||
53 | let mut s = crossterm().unwrap(); | 72 | let mut s = crossterm().unwrap(); |
73 | |||
74 | #[cfg(target_os = "linux")] | ||
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", |