refactor: replace Ctx::new with Ctx::From<PathBuf>
Some checks failed
Test / build (map[name:nightly]) (push) Successful in 2m20s
Test / build (map[name:stable]) (push) Successful in 2m7s
Release Please / Release-plz (push) Failing after 43s

This commit is contained in:
Paul Campbell 2024-12-15 17:55:23 +00:00
parent 1c82ed3a80
commit d511c98e47
3 changed files with 15 additions and 3 deletions

View file

@ -67,8 +67,8 @@ pub struct Ctx {
pub net: Net,
pub prt: Printer,
}
impl Ctx {
pub fn new(base: impl Into<PathBuf>) -> Self {
impl From<PathBuf> for Ctx {
fn from(base: PathBuf) -> Self {
Self {
fs: kxio::fs::new(base),
net: kxio::net::new(),

View file

@ -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
}

View file

@ -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);
}