diff --git a/src/cli/cmd/init/handlers/elixir.rs b/src/cli/cmd/init/handlers/elixir.rs new file mode 100644 index 00000000..60c05d15 --- /dev/null +++ b/src/cli/cmd/init/handlers/elixir.rs @@ -0,0 +1,22 @@ +use crate::cli::cmd::init::{project::Project, prompt::Prompt}; + +use super::{Flake, Handler}; + +const ELIXIR_LATEST: &str = "elixir_1_15"; +const ERLANG_LATEST: &str = "erlang_26"; + +pub(crate) struct Elixir; + +impl Handler for Elixir { + fn handle(project: &Project, flake: &mut Flake) { + if project.has_file("mix.exs") && Prompt::for_language("Elixir") { + flake.dev_shell_packages.push(String::from(ELIXIR_LATEST)); + flake.dev_shell_packages.push(String::from("elixir_ls")); + flake.dev_shell_packages.push(String::from(ERLANG_LATEST)); + + if Prompt::bool("Would you like to add Livebook to the environment?") { + flake.dev_shell_packages.push(String::from("livebook")); + } + } + } +} diff --git a/src/cli/cmd/init/handlers/elm.rs b/src/cli/cmd/init/handlers/elm.rs index ffaacf24..0481b364 100644 --- a/src/cli/cmd/init/handlers/elm.rs +++ b/src/cli/cmd/init/handlers/elm.rs @@ -1,11 +1,11 @@ use crate::cli::cmd::init::{project::Project, prompt::Prompt}; -use super::Handler; +use super::{Flake, Handler}; pub(crate) struct Elm; impl Handler for Elm { - fn handle(project: &Project, flake: &mut super::Flake) { + fn handle(project: &Project, flake: &mut Flake) { if project.has_file("elm.json") && Prompt::for_language("Elm") { flake .dev_shell_packages diff --git a/src/cli/cmd/init/handlers/mod.rs b/src/cli/cmd/init/handlers/mod.rs index f460c358..4494383e 100644 --- a/src/cli/cmd/init/handlers/mod.rs +++ b/src/cli/cmd/init/handlers/mod.rs @@ -1,6 +1,7 @@ use serde::Serialize; use std::collections::HashMap; +pub(crate) mod elixir; pub(crate) mod elm; pub(crate) mod go; pub(crate) mod java; @@ -13,6 +14,7 @@ pub(crate) mod system; pub(crate) mod tools; pub(crate) mod zig; +pub(crate) use elixir::Elixir; pub(crate) use elm::Elm; pub(crate) use go::Go; pub(crate) use java::Java; diff --git a/src/cli/cmd/init/mod.rs b/src/cli/cmd/init/mod.rs index 2339fd40..89fe061d 100644 --- a/src/cli/cmd/init/mod.rs +++ b/src/cli/cmd/init/mod.rs @@ -22,7 +22,8 @@ use super::FlakeHubClient; use self::{ dev_shell::DevShell, handlers::{ - Flake, Go, Handler, Input, Java, JavaScript, Php, Python, Ruby, Rust, System, Tools, Zig, + Elixir, Flake, Go, Handler, Input, Java, JavaScript, Php, Python, Ruby, Rust, System, + Tools, Zig, }, project::Project, template::TemplateData, @@ -137,6 +138,7 @@ impl CommandExecute for InitSubcommand { ); // Languages + Elixir::handle(&project, &mut flake); Elm::handle(&project, &mut flake); Go::handle(&project, &mut flake); Java::handle(&project, &mut flake);