diff --git a/src/fuzzer.rs b/src/input.rs similarity index 95% rename from src/fuzzer.rs rename to src/input.rs index 48190f4..5d59b73 100644 --- a/src/fuzzer.rs +++ b/src/input.rs @@ -5,7 +5,7 @@ use console::{Key, Term, style}; use fuzzy_matcher::skim::SkimMatcherV2; use itertools::Itertools; -pub fn show_selection(term: &mut Term, data: Vec<(String, T)>, name: &str) -> Result { +pub fn input_selection(term: &mut Term, data: Vec<(String, T)>, name: &str) -> Result { let mut filter = "".to_string(); write!(term, "{}:", name)?; diff --git a/src/main.rs b/src/main.rs index 6c3ef79..6a4f8ba 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,10 +11,10 @@ use color_eyre::eyre::{Ok, Result}; use console::Term; use itertools::Itertools; -use crate::fuzzer::show_selection; +use crate::input::input_selection; use crate::project::Project; -mod fuzzer; +mod input; mod project; #[derive(Parser)] @@ -48,17 +48,15 @@ fn update() -> Result<()> { .map(|path| (path.to_str().unwrap_or_default().to_string(), path)) .collect_vec(); - let project = show_selection(&mut term, paths, "Project")?; - - let path = current_dir()?.join(project).join("compose.yml"); - let project = Project::new(&path)?; + let project = input_selection(&mut term, paths, "Project")?; + let project = Project::new(&project)?; let services = project .services()? .into_iter() .map(|service| (service.clone(), service)) .collect_vec(); - let service = show_selection(&mut term, services, "Service")?; + let service = input_selection(&mut term, services, "Service")?; writeln!(term, "services: {:?}", service)?; diff --git a/src/project.rs b/src/project.rs index 4f2f30d..29a548b 100644 --- a/src/project.rs +++ b/src/project.rs @@ -1,4 +1,4 @@ -use std::{fs, path::Path}; +use std::{env::current_dir, fs, path::Path}; use color_eyre::eyre::{ContextCompat, Result}; use serde_yml::Value; @@ -9,6 +9,8 @@ pub struct Project { impl Project { pub fn new(path: &Path) -> Result { + let path = current_dir()?.join(path).join("compose.yml"); + let file = fs::read_to_string(path)?; let value: Value = serde_yml::from_str(&file)?;