diff --git a/src/lib.rs b/src/lib.rs index 8aec10c..1d2600c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -67,8 +67,8 @@ pub struct Ctx { pub net: Net, pub prt: Printer, } -impl Ctx { - pub fn new(base: impl Into) -> Self { +impl From for Ctx { + fn from(base: PathBuf) -> Self { Self { fs: kxio::fs::new(base), net: kxio::net::new(), diff --git a/src/main.rs b/src/main.rs index 7b8210e..e28dab2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,5 +6,5 @@ use trello_to_deck::{run, Ctx}; #[tokio::main] #[cfg_attr(test, mutants::skip)] async fn main() -> Result<()> { - run(Ctx::new(std::env::current_dir()?)).await + run(Ctx::from(std::env::current_dir()?)).await } diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 6d1fc62..01c8c6d 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -15,3 +15,15 @@ mod config; pub(crate) mod given; mod init; mod template; + +#[test] +fn ctx_from_pathbuf() { + //given + let pathbuf = std::path::PathBuf::from("test"); + + //when + let ctx = Ctx::from(pathbuf.clone()); + + //then + assert_peq!(ctx.fs.base(), pathbuf); +} \ No newline at end of file