Implement 'today new'
This commit is contained in:
parent
0dcb75b103
commit
3befb7c773
8 changed files with 174 additions and 5 deletions
18
src/cli.rs
18
src/cli.rs
|
|
@ -19,6 +19,7 @@ mod done;
|
|||
mod error;
|
||||
mod layout;
|
||||
mod log;
|
||||
mod new;
|
||||
mod print;
|
||||
mod show;
|
||||
mod util;
|
||||
|
|
@ -47,6 +48,12 @@ pub enum Command {
|
|||
#[structopt(required = true)]
|
||||
identifiers: Vec<String>,
|
||||
},
|
||||
/// Create a new entry based on a template
|
||||
#[structopt(alias = "n")]
|
||||
New {
|
||||
#[structopt(subcommand)]
|
||||
template: Template,
|
||||
},
|
||||
/// Marks one or more entries as done
|
||||
#[structopt(alias = "d")]
|
||||
Done {
|
||||
|
|
@ -71,6 +78,14 @@ pub enum Command {
|
|||
Fmt,
|
||||
}
|
||||
|
||||
// TODO Add templates for tasks and notes
|
||||
#[derive(Debug, StructOpt)]
|
||||
pub enum Template {
|
||||
/// An undated task marked as done today
|
||||
#[structopt(alias = "d")]
|
||||
Done,
|
||||
}
|
||||
|
||||
fn default_file() -> PathBuf {
|
||||
ProjectDirs::from("", "", "today")
|
||||
.expect("could not determine config dir")
|
||||
|
|
@ -136,6 +151,9 @@ fn run_command(opt: &Opt, files: &mut Files, range: DateRange, now: NaiveDateTim
|
|||
let idents = parse_show_idents(identifiers, now.date())?;
|
||||
show::show(files, &entries, &layout, &idents);
|
||||
}
|
||||
Some(Command::New { template }) => match template {
|
||||
Template::Done => new::done(files, now)?,
|
||||
},
|
||||
Some(Command::Done { entries: ns }) => {
|
||||
let entries = find_entries(files, range)?;
|
||||
let layout = find_layout(files, &entries, range, now);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue