55 lines
1.4 KiB
Rust
55 lines
1.4 KiB
Rust
![]() |
use std::convert::TryFrom;
|
||
|
use std::io::Write;
|
||
|
|
||
|
use clap::ArgMatches;
|
||
|
use chrono::{DateTime, Utc};
|
||
|
use regex::Regex;
|
||
|
|
||
|
use crate::database::{Database, DBVersion};
|
||
|
use crate::error::{Error, Result};
|
||
|
use crate::commands::Command;
|
||
|
use crate::config::Config;
|
||
|
use crate::timeparse::parse_time;
|
||
|
use crate::old::{entries_or_warning, time_or_warning, warn_if_needed};
|
||
|
use crate::formatters::text;
|
||
|
use crate::editor;
|
||
|
use crate::regex::parse_regex;
|
||
|
|
||
|
#[derive(Default)]
|
||
|
pub struct Args {
|
||
|
start: Option<DateTime<Utc>>,
|
||
|
end: Option<DateTime<Utc>>,
|
||
|
grep: Option<Regex>,
|
||
|
fake: bool,
|
||
|
sheet: Option<String>,
|
||
|
}
|
||
|
|
||
|
impl<'a> TryFrom<&'a ArgMatches<'a>> for Args {
|
||
|
type Error = Error;
|
||
|
|
||
|
fn try_from(matches: &'a ArgMatches) -> Result<Self> {
|
||
|
Ok(Args {
|
||
|
start: matches.value_of("start").map(|s| parse_time(s)).transpose()?,
|
||
|
end: matches.value_of("end").map(|s| parse_time(s)).transpose()?,
|
||
|
grep: matches.value_of("grep").map(parse_regex).transpose()?,
|
||
|
fake: matches.is_present("fake"),
|
||
|
sheet: matches.value_of("sheet").map(|s| s.to_owned()),
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pub struct ArchiveCommand {}
|
||
|
|
||
|
impl<'a> Command<'a> for ArchiveCommand {
|
||
|
type Args = Args;
|
||
|
|
||
|
fn handle<D, O, E>(args: Args, db: &mut D, out: &mut O, err: &mut E, config: &Config, now: DateTime<Utc>) -> Result<()>
|
||
|
where
|
||
|
D: Database,
|
||
|
O: Write,
|
||
|
E: Write,
|
||
|
{
|
||
|
unimplemented!()
|
||
|
}
|
||
|
}
|