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