Skip to content

Commit

Permalink
feat: use default dockerfile if found (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHedmad committed Feb 5, 2024
1 parent 5d223c2 commit e37ff4f
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,15 @@ impl Pipe {

impl Display for Pipe {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let container_prefix = if self.env_path.is_none() { "" } else { "🐋" };
let container_prefix = if self.env_path.is_none() {
""
} else {
if self.env_path.clone().unwrap().file_stem().unwrap() == "default" {
"🐟"
} else {
"🐋"
}
};
let desc_prefix = if self
.description()
.expect("Could not parse description file")
Expand Down Expand Up @@ -408,6 +416,11 @@ impl KerblamTomlOptions {
// TODO: I duct-taped this loop with inner clone(), but I'm 76% sure
// that we can do it with references.

let default_dockerfile: Option<PathBuf> = envs_names
.iter()
.find(|(name, _)| name == "default")
.and_then(|(_, path)| Some(path.to_owned()));

for (pipe_name, pipe_path) in pipes_names {
let mut found = false;
for (env_name, env_path) in envs_names.clone() {
Expand All @@ -422,11 +435,13 @@ impl KerblamTomlOptions {
if !found {
pipes.push(Pipe {
pipe_path,
env_path: None,
env_path: default_dockerfile.clone(),
})
}
}

log::debug!("Found pipes: {pipes:?}");

pipes
}

Expand Down

0 comments on commit e37ff4f

Please sign in to comment.