From 9dfe454cd8bc816522446e7e3b9f45630c886112 Mon Sep 17 00:00:00 2001 From: Guillaume Hormiere Date: Wed, 22 Jul 2020 00:38:01 +0200 Subject: Add list command for shell script purpose Usage dijo -l for printing the habit names list Add check on habit add to avoid duplicate habits --- src/main.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index d96119e..050a296 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,6 +33,14 @@ fn main() { .value_name("CMD") .help("run a dijo command"), ) + .arg( + Arg::with_name("list") + .short("l") + .long("list") + .takes_value(false) + .help("list dijo habits") + .conflicts_with("command"), + ) .get_matches(); if let Some(c) = matches.value_of("command") { let command = Command::from_string(c); @@ -49,6 +57,12 @@ fn main() { "Commands other than `track-up` and `track-down` are currently not supported!" ), } + } else if matches.is_present("list") { + let app = App::load_state(); + let _habit_names = app.list_habit(); + for h in _habit_names { + println!("{}", h); + } } else { let mut s = termion().unwrap(); let app = App::load_state(); -- cgit v1.2.3 From b0b6c04a052955834f0603df79db7a0a517a9b9d Mon Sep 17 00:00:00 2001 From: Akshay Date: Thu, 23 Jul 2020 13:19:15 +0530 Subject: move duplicate check to command parsing block --- src/main.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 050a296..5523073 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,9 +58,7 @@ fn main() { ), } } else if matches.is_present("list") { - let app = App::load_state(); - let _habit_names = app.list_habit(); - for h in _habit_names { + for h in App::load_state().list_habits() { println!("{}", h); } } else { -- cgit v1.2.3 From 7322949561fdbdc36a811b1368222fb5a2bf050a Mon Sep 17 00:00:00 2001 From: Akshay Date: Mon, 20 Jul 2020 11:38:20 +0530 Subject: switch to crossterm backend --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 5523073..3e35ebc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,7 @@ use crate::command::{open_command_window, Command}; use crate::utils::{load_configuration_file, AppConfig}; use clap::{App as ClapApp, Arg}; -use cursive::termion; +use cursive::crossterm; use cursive::views::{LinearLayout, NamedView}; use lazy_static::lazy_static; @@ -62,7 +62,7 @@ fn main() { println!("{}", h); } } else { - let mut s = termion().unwrap(); + let mut s = crossterm().unwrap(); let app = App::load_state(); let layout = NamedView::new( "Frame", -- cgit v1.2.3