tiempo-rs/src/commands/sheet.rs

59 lines
1.1 KiB
Rust
Raw Normal View History

2021-07-01 23:44:38 -05:00
use std::convert::TryFrom;
use std::io::Write;
use clap::ArgMatches;
use crate::database::Database;
2021-07-14 12:37:08 -05:00
use crate::error::{Error, Result};
2021-07-01 23:44:38 -05:00
use crate::commands::Command;
use crate::config::Config;
#[derive(Default)]
pub struct Args {
sheet: Option<String>,
}
impl<'a> TryFrom<&'a ArgMatches<'a>> for Args {
2021-07-14 12:37:08 -05:00
type Error = Error;
2021-07-01 23:44:38 -05:00
2021-07-14 12:37:08 -05:00
fn try_from(matches: &'a ArgMatches) -> Result<Self> {
2021-07-01 23:44:38 -05:00
Ok(Args {
sheet: matches.value_of("sheet").map(|s| s.into()),
})
}
}
pub struct SheetCommand {}
impl<'a> Command<'a> for SheetCommand {
type Args = Args;
2021-07-14 12:37:08 -05:00
fn handle<D, O, E>(args: Args, _db: &mut D, _out: &mut O, _err: &mut E, _config: &Config) -> Result<()>
2021-07-01 23:44:38 -05:00
where
D: Database,
O: Write,
E: Write,
{
2021-07-14 12:37:08 -05:00
if let Some(_sheet) = args.sheet {
// sheet given, switch to it
unimplemented!()
} else {
// call list
Ok(())
}
2021-07-01 23:44:38 -05:00
}
}
#[cfg(test)]
mod tests {
#[test]
fn switch_to_sheet() {
assert!(false);
}
#[test]
fn switch_to_sheet_already_in() {
assert!(false);
}
}