Verified Commit 474257f7 authored by Maxime Buquet's avatar Maxime Buquet
Browse files

cli: Update example; remove parsers


Signed-off-by: Maxime Buquet's avatarMaxime “pep” Buquet <pep@bouah.net>
parent e3fa2d6b
......@@ -7,7 +7,6 @@
#[macro_use]
extern crate clap;
// #[macro_use]
extern crate env_logger;
extern crate log;
......@@ -20,12 +19,6 @@ use std::io::prelude::*;
use std::io::Error as IOError;
use std::path::Path;
use chrono::NaiveTime;
use nom::types::CompleteStr;
use timelog::helpers::split_by_days;
use timelog::parsers::parse_entries;
use timelog::types::TimesheetDay;
pub fn read_file<P: AsRef<Path>>(path: P) -> Result<String, IOError> {
let mut fh = File::open(path)?;
let mut file = String::new();
......@@ -43,31 +36,5 @@ fn main() {
let filename = matches.value_of("file").unwrap();
let timelogs = read_file(filename).unwrap();
let timelogs = timelogs.as_ref();
println!("Timelogs: {:?}", timelogs);
match parse_entries(CompleteStr(timelogs)) {
Ok((i, entries)) => {
// TODO: Should always be empty, otherwise make the parser return an Err
println!("Input: {:?}", i);
println!("Entries: {:?}", entries);
let virtual_midnight = NaiveTime::parse_from_str("04:00", "%H:%M").unwrap();
let days = split_by_days(entries, virtual_midnight);
println!("Days: {:?}", days);
if let Ok(days) = days {
let timesheets: Vec<TimesheetDay> = days
.into_iter()
.map(|d| {
println!("Day: {:?}", d);
TimesheetDay::from(d)
})
.collect();
println!("Timesheet: {:?}", timesheets);
}
}
Err(err) => println!("Entries error: {:?}", err),
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment