use clap::{CommandFactory, FromArgMatches}; use color_eyre::Result; use std::ffi::OsStr; use fix_und_fertig::cli::Cli; pub fn tmpdir() -> tempfile::TempDir { tempfile::TempDir::new().unwrap() } pub fn run_in>(dir: &tempfile::TempDir, args: impl AsRef<[S]>) -> Result<()> { let mut matches = ::command().get_matches_from( [OsStr::new("fuf")] .into_iter() .chain(args.as_ref().into_iter().map(AsRef::as_ref)), ); let cli = ::from_arg_matches_mut(&mut matches).expect("invalid CLI args"); fix_und_fertig::cli::run_command(dir.path(), cli) }