summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/actions/new.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/actions/new.rs b/src/actions/new.rs
index 39cfe0b..e75dd34 100644
--- a/src/actions/new.rs
+++ b/src/actions/new.rs
@@ -5,6 +5,7 @@ use crate::icalwrap::{IcalTime, IcalVCalendar};
use crate::khline::KhLine;
use crate::utils::{fileutil, misc};
use crate::KhResult;
+use std::path::PathBuf;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
@@ -96,9 +97,7 @@ pub fn do_new(args: &NewArgs) -> KhResult<()> {
let uid = misc::make_new_uid();
let ep = EventProperties::parse_from_args(args)?;
- let mut path = defaults::get_caldir();
- path.push(&ep.calendar);
- path.push(&(uid.clone() + ".ics"));
+ let path = assemble_file_path(&ep.calendar, &uid);
let new_cal = IcalVCalendar::from_str(TEMPLATE_EVENT, Some(&path))?
.with_uid(&uid)?
@@ -116,6 +115,14 @@ pub fn do_new(args: &NewArgs) -> KhResult<()> {
Ok(())
}
+fn assemble_file_path(cal_name: &String, uid: &String ) -> PathBuf {
+ let mut path = defaults::get_caldir();
+ path.push(cal_name);
+ path.push(uid);
+ path.set_extension("ics");
+ path
+}
+
impl IcalVCalendar {
fn with_eventprops(self, ep: &EventProperties) -> Self {
self