summaryrefslogtreecommitdiffstats
path: root/archive
diff options
context:
space:
mode:
authorNora <nora.widdecke@tu-bs.de>2019-03-11 11:22:48 +0100
committerNora <nora.widdecke@tu-bs.de>2019-03-11 11:22:48 +0100
commit841a25660ea1f507dc0c02c74f172ef515bdd259 (patch)
tree914b64830d339ff208db1cc650749dcaedbe12bc /archive
parent1ffc0d1d39a6d5db5969c1af667bc412b195a97b (diff)
move prettyprint to archive
Diffstat (limited to 'archive')
-rw-r--r--archive/prettyprint.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/archive/prettyprint.rs b/archive/prettyprint.rs
new file mode 100644
index 0000000..6b7fdad
--- /dev/null
+++ b/archive/prettyprint.rs
@@ -0,0 +1,37 @@
+use crate::icalwrap::{IcalComponent,IcalProperty};
+use std::path::Path;
+use crate::input;
+use crate::KhResult;
+
+pub fn prettyprint() -> KhResult<()> {
+ let lines = input::default_input_khlines()?;
+ for line in lines {
+ let event = line.to_event()?.event;
+ prettyprint_comp(&event, line.get_path());
+ }
+ Ok(())
+}
+
+pub fn prettyprint_comp(cal: &IcalComponent, path: &Path) {
+ let properties = cal.get_properties_all();
+ 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),
+ }
+}
+