Skip to content

Commit

Permalink
Merge pull request #90 from DeterminateSystems/elixir-init
Browse files Browse the repository at this point in the history
Add Elixir detection
  • Loading branch information
lucperkins authored Dec 6, 2023
2 parents b79c8fd + 0fdeee3 commit c321ac4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
22 changes: 22 additions & 0 deletions src/cli/cmd/init/handlers/elixir.rs
Original file line number Diff line number Diff line change
@@ -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"));
}
}
}
}
4 changes: 2 additions & 2 deletions src/cli/cmd/init/handlers/elm.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/cli/cmd/init/handlers/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/cli/cmd/init/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c321ac4

Please sign in to comment.