summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/icalwrap/icalvcalendar.rs8
-rw-r--r--src/icalwrap/icalvevent.rs2
-rw-r--r--src/prettyprint.rs11
-rw-r--r--src/unroll.rs4
4 files changed, 15 insertions, 10 deletions
diff --git a/src/icalwrap/icalvcalendar.rs b/src/icalwrap/icalvcalendar.rs
index 2fd3545..04c600d 100644
--- a/src/icalwrap/icalvcalendar.rs
+++ b/src/icalwrap/icalvcalendar.rs
@@ -108,7 +108,7 @@ impl IcalVCalendar {
{
let events = self.events_iter();
if events.unique_uid_count() > 1 {
- return Err(format!("More than one event in file: {}", self.get_path_as_string()));
+ return Err(format!("More than one event in file: {}", self.get_path_as_string().unwrap_or_else(|| "".to_string())));
}
let events = self.events_iter();
let uid_cstr = CString::new(uid).unwrap();
@@ -184,8 +184,8 @@ impl IcalVCalendar {
}
}
- pub fn get_path_as_string(&self) -> String {
- format!("{}", self.path.as_ref().unwrap().display())
+ pub fn get_path_as_string(&self) -> Option<String> {
+ self.path.as_ref().map(|path| format!("{}", path.display()))
}
pub fn get_path(&self) -> Option<&PathBuf> {
@@ -209,7 +209,7 @@ impl IcalVCalendar {
)
};
if self.events_iter().unique_uid_count() > 1 {
- warn!("More than one event in file: {}", self.get_path_as_string())
+ warn!("More than one event in file: {}", self.get_path_as_string().unwrap_or_else(|| "".to_string()))
}
IcalVEvent::from_ptr_with_parent(event, self)
}
diff --git a/src/icalwrap/icalvevent.rs b/src/icalwrap/icalvevent.rs
index 1e66a8c..658a757 100644
--- a/src/icalwrap/icalvevent.rs
+++ b/src/icalwrap/icalvevent.rs
@@ -142,7 +142,7 @@ impl IcalVEvent {
pub fn get_khaleesi_line(&self) -> Option<String> {
let dtstart = self.get_dtstart()?.timestamp();
let dtstart_string = format!("{:010}", dtstart);
- let path_string = self.parent.as_ref()?.get_path_as_string();
+ let path_string = self.parent.as_ref()?.get_path_as_string()?;
Some([dtstart_string, path_string].join(" "))
}
diff --git a/src/prettyprint.rs b/src/prettyprint.rs
index 81ad1b5..0baef7d 100644
--- a/src/prettyprint.rs
+++ b/src/prettyprint.rs
@@ -4,16 +4,21 @@ use utils::fileutil;
pub fn prettyprint(lines: &mut Iterator<Item = String>) {
let cals = fileutil::read_calendars_from_files(lines).unwrap();
for cal in cals {
- prettyprint_comp(&cal);
+ let event = cal.get_principal_event();
+ prettyprint_comp(&event, cal.get_path_as_string());
}
}
-pub fn prettyprint_comp(cal: &IcalVCalendar) {
+pub fn prettyprint_comp(cal: &IcalComponent, path: Option<String>) {
let properties = cal.get_properties_all();
- println!("num: {}", properties.len());
+ if let Some(path) = path {
+ debug!("path: {}", path);
+ }
+ debug!("property count: {}", properties.len());
for property in properties {
prettyprint_prop(&property);
}
+ println!();
}
fn prettyprint_prop(property: &IcalProperty) {
diff --git a/src/unroll.rs b/src/unroll.rs
index 49c4cf1..156432f 100644
--- a/src/unroll.rs
+++ b/src/unroll.rs
@@ -3,12 +3,12 @@ use std::path::Path;
use utils::fileutil as utils;
pub fn do_unroll(filepath: &Path) {
- let cal = utils::read_calendar_from_path(filepath).unwrap();
+ let cal = utils::read_calendar_from_path(filepath).unwrap();
for event in cal.events_iter() {
if event.has_recur() {
let recurs = event.get_recur_datetimes();
for datetime in recurs {
- println!("{} {}", datetime.timestamp(), cal.get_path_as_string());
+ println!("{} {}", datetime.timestamp(), cal.get_path_as_string().unwrap_or_else(|| "".to_string()));
}
}
}