diff options
Diffstat (limited to 'src/bin/jt2.rs')
-rw-r--r-- | src/bin/jt2.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/bin/jt2.rs b/src/bin/jt2.rs index 25a3a13..677bb35 100644 --- a/src/bin/jt2.rs +++ b/src/bin/jt2.rs @@ -3,7 +3,7 @@ use jt2::error::JournalError; use jt2::journal::Journal; use jt2::opt::{Opt, SubCommand}; -use std::path::Path; +use std::path::{Path, PathBuf}; use structopt::StructOpt; fn main() -> anyhow::Result<()> { @@ -17,7 +17,8 @@ fn main() -> anyhow::Result<()> { description, } => init(&config.dirname, &journalname, &description, &config)?, SubCommand::IsJournal => is_journal(&config)?, - SubCommand::New { title } => new_draft(&title, &config)?, + SubCommand::New { title, topic } => new_draft(&title, &topic, &config)?, + SubCommand::NewTopic { path, title } => new_topic(&path, &title, &config)?, SubCommand::Edit { draft } => edit_draft(&draft, &config)?, SubCommand::Finish { draft, basename } => finish_draft(&draft, &basename, &config)?, } @@ -41,9 +42,15 @@ fn is_journal(config: &Configuration) -> anyhow::Result<()> { Ok(()) } -fn new_draft(title: &str, config: &Configuration) -> anyhow::Result<()> { +fn new_draft(title: &str, topic: &Option<PathBuf>, config: &Configuration) -> anyhow::Result<()> { let journal = Journal::new(&config.dirname, &config.entries)?; - journal.new_draft(title, &config.editor)?; + journal.new_draft(title, topic, &config.editor)?; + Ok(()) +} + +fn new_topic(path: &Path, title: &str, config: &Configuration) -> anyhow::Result<()> { + let journal = Journal::new(&config.dirname, &config.entries)?; + journal.new_topic(path, title, &config.editor)?; Ok(()) } |