summaryrefslogtreecommitdiffstats
path: root/src/actions/prettyprint.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/actions/prettyprint.rs')
-rw-r--r--src/actions/prettyprint.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/actions/prettyprint.rs b/src/actions/prettyprint.rs
new file mode 100644
index 0000000..0baef7d
--- /dev/null
+++ b/src/actions/prettyprint.rs
@@ -0,0 +1,36 @@
+use icalwrap::{IcalComponent,IcalProperty};
+use utils::fileutil;
+
+pub fn prettyprint(lines: &mut Iterator<Item = String>) {
+ let cals = fileutil::read_calendars_from_files(lines).unwrap();
+ for cal in cals {
+ let event = cal.get_principal_event();
+ prettyprint_comp(&event, cal.get_path_as_string());
+ }
+}
+
+pub fn prettyprint_comp(cal: &IcalComponent, path: Option<String>) {
+ let properties = cal.get_properties_all();
+ 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) {
+ let name = property.get_name();
+ let value = property.get_value();
+ match name.as_str() {
+ "DTSTART" => {
+ let date = property.get_value_as_date();
+ println!("start: {}", date.unwrap());
+ },
+ "DESCRIPTION" => println!("description: {}", value),
+ _ => println!("{} - {}", name, value),
+ }
+}
+