time entry representation change, and basic statistics

This commit is contained in:
aaron-jack-manning
2022-08-24 09:56:23 +10:00
parent 1d04723bd7
commit 43f8bc043b
4 changed files with 170 additions and 37 deletions

View File

@@ -4,6 +4,7 @@ mod vault;
mod error;
mod tasks;
mod state;
mod stats;
mod config;
mod colour;
@@ -82,6 +83,9 @@ enum Command {
#[clap(short, default_value_t=0)]
minutes : u16,
},
/// For statistics about the state of your vault.
#[clap(subcommand)]
Stats(StatsCommand),
/// For making changes to global configuration.
#[clap(subcommand)]
Config(ConfigCommand),
@@ -94,6 +98,15 @@ enum Command {
},
}
#[derive(clap::Subcommand, Debug, PartialEq, Eq)]
enum StatsCommand {
Tracked {
#[clap(short, long, default_value_t=7)]
days : u16,
},
}
#[derive(clap::Subcommand, Debug, PartialEq, Eq)]
enum ConfigCommand {
/// For checking or changing default text editor command.
@@ -251,6 +264,14 @@ fn program() -> Result<(), error::Error> {
task.data.time_entries.push(entry);
task.save()?;
},
Stats(command) => {
use StatsCommand::*;
match command {
Tracked { days } => {
stats::time_per_tag(days, vault_folder)?;
}
}
},
Discard { id_or_name } => {
let id = state.name_or_id_to_id(&id_or_name)?;
let mut task = tasks::Task::load(id, vault_folder, false)?;