Skip to content

Commit

Permalink
Update ShellProgramNotFound error diagnostics format and snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
enkerewpo authored and lpil committed Dec 23, 2024
1 parent c62b53a commit 7b4d8de
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 43 deletions.
71 changes: 37 additions & 34 deletions compiler-core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,43 @@ your app.src file \"{app_ver}\"."
}

Error::ShellProgramNotFound { program , os } => {
let mut text = format!("The program `{program}` was not found. Is it installed?\n");
let mut text = format!("The program `{program}` was not found. Is it installed?");

match os {
OS::MacOS => {
fn brew_install(name: &str, pkg: &str) -> String {
format!("\n\nYou can install {} via homebrew: brew install {}", name, pkg)
}
match program.as_str() {
"erl" | "erlc" | "escript" => text.push_str(&brew_install("Erlang", "erlang")),
"rebar3" => text.push_str(&brew_install("Rebar3", "rebar3")),
"deno" => text.push_str(&brew_install("Deno", "deno")),
"elixir" => text.push_str(&brew_install("Elixir", "elixir")),
"node" => text.push_str(&brew_install("Node.js", "node")),
"bun" => text.push_str(&brew_install("Bun", "oven-sh/bun/bun")),
"git" => text.push_str(&brew_install("Git", "git")),
_ => (),
}
}
OS::Linux(distro) => {
fn apt_install(name: &str, pkg: &str) -> String {
format!("\n\nYou can install {} via apt: sudo apt install {}", name, pkg)
}
match distro {
Distro::Ubuntu | Distro::Debian => {
match program.as_str() {
"elixir" => text.push_str(&apt_install("Elixir", "elixir")),
"git" => text.push_str(&apt_install("Git", "git")),
_ => (),
}
}
Distro::Other => (),
}
}
_ => (),
}

text.push('\n');

match program.as_str() {
"erl" | "erlc" | "escript" => text.push_str(
Expand Down Expand Up @@ -1092,39 +1128,6 @@ https://git-scm.com/book/en/v2/Getting-Started-Installing-Git",
),
_ => (),
}
match os {
OS::MacOS => {
fn brew_install(program: &str) -> String {
format!("\nYou can install {} via homebrew: brew install {}", program, program)
}
match program.as_str() {
"erl" | "erlc" | "escript" => text.push_str(&brew_install("erlang")),
"rebar3" => text.push_str(&brew_install("rebar3")),
"deno" => text.push_str(&brew_install("deno")),
"elixir" => text.push_str(&brew_install("elixir")),
"node" => text.push_str(&brew_install("node")),
"bun" => text.push_str(&brew_install("oven-sh/bun/bun")),
"git" => text.push_str(&brew_install("git")),
_ => (),
}
}
OS::Linux(distro) => {
fn apt_install(program: &str) -> String {
format!("\nYou can install {} via apt: sudo apt install {}", program, program)
}
match distro {
Distro::Ubuntu | Distro::Debian => {
match program.as_str() {
"elixir" => text.push_str(&apt_install("elixir")),
"git" => text.push_str(&apt_install("git")),
_ => (),
}
}
Distro::Other => (),
}
}
_ => (),
}

vec![Diagnostic {
title: "Program not found".into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ expression: "err[0].text"
---
The program `bun` was not found. Is it installed?

You can install Bun via homebrew: brew install oven-sh/bun/bun

Documentation for installing bun can be viewed here:
https://bun.sh/docs/installation/
You can install oven-sh/bun/bun via homebrew: brew install oven-sh/bun/bun
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ expression: "err[0].text"
---
The program `deno` was not found. Is it installed?

You can install Deno via homebrew: brew install deno

Documentation for installing Deno can be viewed here:
https://docs.deno.com/runtime/getting_started/installation/
You can install deno via homebrew: brew install deno
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ expression: "err[0].text"
---
The program `elixir` was not found. Is it installed?

You can install Elixir via apt: sudo apt install elixir

Documentation for installing Elixir can be viewed here:
https://elixir-lang.org/install.html
You can install elixir via apt: sudo apt install elixir
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ expression: "err[0].text"
---
The program `elixir` was not found. Is it installed?

You can install Elixir via homebrew: brew install elixir

Documentation for installing Elixir can be viewed here:
https://elixir-lang.org/install.html
You can install elixir via homebrew: brew install elixir
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ expression: "err[0].text"
---
The program `erlc` was not found. Is it installed?

You can install Erlang via homebrew: brew install erlang

Documentation for installing Erlang can be viewed here:
https://gleam.run/getting-started/installing/
You can install erlang via homebrew: brew install erlang
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ expression: "err[0].text"
---
The program `git` was not found. Is it installed?

You can install Git via apt: sudo apt install git

Documentation for installing Git can be viewed here:
https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
You can install git via apt: sudo apt install git
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ expression: "err[0].text"
---
The program `git` was not found. Is it installed?

You can install Git via homebrew: brew install git

Documentation for installing Git can be viewed here:
https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
You can install git via homebrew: brew install git
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ expression: "err[0].text"
---
The program `node` was not found. Is it installed?

You can install Node.js via homebrew: brew install node

Documentation for installing Node.js via package manager can be viewed here:
https://nodejs.org/en/download/package-manager/all/
You can install node via homebrew: brew install node
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ expression: "err[0].text"
---
The program `rebar3` was not found. Is it installed?

You can install Rebar3 via homebrew: brew install rebar3

Documentation for installing rebar3 can be viewed here:
https://rebar3.org/docs/getting-started/
You can install rebar3 via homebrew: brew install rebar3

0 comments on commit 7b4d8de

Please sign in to comment.