From d3a6228a08e7b91a88f3e462a5f882dc67a3cb29 Mon Sep 17 00:00:00 2001 From: Kevin Goslar Date: Sat, 11 Nov 2023 06:32:21 -0600 Subject: [PATCH 1/8] gh.rs mod.rs --- src/apps/gh.rs | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ src/apps/mod.rs | 3 +++ 2 files changed, 67 insertions(+) create mode 100644 src/apps/gh.rs diff --git a/src/apps/gh.rs b/src/apps/gh.rs new file mode 100644 index 00000000..0a127174 --- /dev/null +++ b/src/apps/gh.rs @@ -0,0 +1,64 @@ +use super::App; +use crate::detect::{Cpu, Os, Platform}; +use crate::hosting::{GithubReleaseAsset, OnlineLocation}; +use big_s::S; + +pub struct Gh {} + +impl App for Gh { + fn name(&self) -> &'static str { + "gh" + } + + fn executable(&self, platform: Platform) -> &'static str { + match platform.os { + Os::Windows => "dprint.exe", + Os::Linux | Os::MacOS => "dprint", + } + } + + fn homepage(&self) -> &'static str { + "https://cli.github.com" + } + + fn artifact_location(&self, version: &str, platform: Platform) -> Box { + let filename = format!( + "gh_{version}_{os}_{cpu}.{ext}", + os = os_text(platform.os), + cpu = cpu_text(platform.cpu), + ext = ext_text(platform.os) + ); + Box::new(GithubReleaseAsset { + organization: "dprint", + repo: "dprint", + version: version.to_string(), + filename, + }) + } + + fn file_to_extract_from_archive(&self, _version: &str, platform: Platform) -> String { + S(self.executable(platform)) + } +} + +fn os_text(os: Os) -> &'static str { + match os { + Os::Windows => "windows", + Os::Linux => "linux", + Os::MacOS => "macOS", + } +} + +fn cpu_text(cpu: Cpu) -> &'static str { + match cpu { + Cpu::Intel64 => "amd64", + Cpu::Arm64 => "arm64", + } +} + +fn ext_text(os: Os) -> &'static str { + match os { + Os::Windows | Os::MacOS => "zip", + Os::Linux => "tgz", + } +} diff --git a/src/apps/mod.rs b/src/apps/mod.rs index 6ce32525..e748fea5 100644 --- a/src/apps/mod.rs +++ b/src/apps/mod.rs @@ -1,6 +1,7 @@ //! all applications that run-this-app can run mod dprint; +mod gh; mod shellcheck; mod shfmt; @@ -9,6 +10,7 @@ use crate::error::UserError; use crate::hosting::OnlineLocation; use crate::Result; use dprint::Dprint; +use gh::Gh; use shellcheck::ShellCheck; use shfmt::Shfmt; @@ -41,6 +43,7 @@ pub trait App { pub fn all() -> Vec> { vec![ Box::new(Dprint {}), + Box::new(Gh {}), Box::new(ShellCheck {}), Box::new(Shfmt {}), ] From 3202649df0b754c931d5a16398df303018144733 Mon Sep 17 00:00:00 2001 From: Kevin Goslar Date: Mon, 13 Nov 2023 09:58:14 -0600 Subject: [PATCH 2/8] gofumpt.rs --- src/apps/gofumpt.rs | 56 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/apps/gofumpt.rs diff --git a/src/apps/gofumpt.rs b/src/apps/gofumpt.rs new file mode 100644 index 00000000..9d026d69 --- /dev/null +++ b/src/apps/gofumpt.rs @@ -0,0 +1,56 @@ +use super::App; +use crate::detect::{Cpu, Os, Platform}; +use crate::hosting::{GithubReleaseAsset, OnlineLocation}; +use big_s::S; + +pub struct Gofumpt {} + +impl App for Gofumpt { + fn name(&self) -> &'static str { + "gofumpt" + } + + fn executable(&self, platform: Platform) -> &'static str { + match platform.os { + Os::Windows => "dprint.exe", + Os::Linux | Os::MacOS => "dprint", + } + } + + fn homepage(&self) -> &'static str { + "https://dprint.dev" + } + + fn artifact_location(&self, version: &str, platform: Platform) -> Box { + let filename = format!( + "dprint-{cpu}-{os}.zip", + os = os_text(platform.os), + cpu = cpu_text(platform.cpu), + ); + Box::new(GithubReleaseAsset { + organization: "dprint", + repo: "dprint", + version: version.to_string(), + filename, + }) + } + + fn file_to_extract_from_archive(&self, _version: &str, platform: Platform) -> String { + S(self.executable(platform)) + } +} + +fn os_text(os: Os) -> &'static str { + match os { + Os::Windows => "pc-windows-msvc", + Os::Linux => "unknown-linux-gnu", + Os::MacOS => "apple-darwin", + } +} + +fn cpu_text(cpu: Cpu) -> &'static str { + match cpu { + Cpu::Intel64 => "x86_64", + Cpu::Arm64 => "aarch64", + } +} From 640958192324a51c111f1184b49af63c86bf6c2a Mon Sep 17 00:00:00 2001 From: Kevin Goslar Date: Mon, 13 Nov 2023 10:04:36 -0600 Subject: [PATCH 3/8] dprint.rs gh.rs gofumpt.rs mod.rs shellcheck.rs shfmt.rs mod.rs --- src/apps/dprint.rs | 4 ++-- src/apps/gh.rs | 4 ++-- src/apps/gofumpt.rs | 17 ++++++++--------- src/apps/mod.rs | 5 ++++- src/apps/shellcheck.rs | 4 ++-- src/apps/shfmt.rs | 4 ++-- src/archives/mod.rs | 10 ++++++---- 7 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/apps/dprint.rs b/src/apps/dprint.rs index ae58c2f1..f716472b 100644 --- a/src/apps/dprint.rs +++ b/src/apps/dprint.rs @@ -35,8 +35,8 @@ impl App for Dprint { }) } - fn file_to_extract_from_archive(&self, _version: &str, platform: Platform) -> String { - S(self.executable(platform)) + fn file_to_extract_from_archive(&self, _version: &str, platform: Platform) -> Option { + Some(S(self.executable(platform))) } } diff --git a/src/apps/gh.rs b/src/apps/gh.rs index 0a127174..f9d54f94 100644 --- a/src/apps/gh.rs +++ b/src/apps/gh.rs @@ -36,8 +36,8 @@ impl App for Gh { }) } - fn file_to_extract_from_archive(&self, _version: &str, platform: Platform) -> String { - S(self.executable(platform)) + fn file_to_extract_from_archive(&self, _version: &str, platform: Platform) -> Option { + Some(S(self.executable(platform))) } } diff --git a/src/apps/gofumpt.rs b/src/apps/gofumpt.rs index 9d026d69..1c808d91 100644 --- a/src/apps/gofumpt.rs +++ b/src/apps/gofumpt.rs @@ -1,7 +1,6 @@ use super::App; use crate::detect::{Cpu, Os, Platform}; use crate::hosting::{GithubReleaseAsset, OnlineLocation}; -use big_s::S; pub struct Gofumpt {} @@ -12,31 +11,31 @@ impl App for Gofumpt { fn executable(&self, platform: Platform) -> &'static str { match platform.os { - Os::Windows => "dprint.exe", - Os::Linux | Os::MacOS => "dprint", + Os::Windows => "gofumpt.exe", + Os::Linux | Os::MacOS => "gofumpt", } } fn homepage(&self) -> &'static str { - "https://dprint.dev" + "https://github.com/mvdan/gofumpt" } fn artifact_location(&self, version: &str, platform: Platform) -> Box { let filename = format!( - "dprint-{cpu}-{os}.zip", + "gofumpt_v{version}_{os}_{cpu}", os = os_text(platform.os), cpu = cpu_text(platform.cpu), ); Box::new(GithubReleaseAsset { - organization: "dprint", - repo: "dprint", + organization: "mvdan", + repo: "gofumpt", version: version.to_string(), filename, }) } - fn file_to_extract_from_archive(&self, _version: &str, platform: Platform) -> String { - S(self.executable(platform)) + fn file_to_extract_from_archive(&self, _version: &str, _platform: Platform) -> Option { + None } } diff --git a/src/apps/mod.rs b/src/apps/mod.rs index e748fea5..38d3536b 100644 --- a/src/apps/mod.rs +++ b/src/apps/mod.rs @@ -2,6 +2,7 @@ mod dprint; mod gh; +mod gofumpt; mod shellcheck; mod shfmt; @@ -11,6 +12,7 @@ use crate::hosting::OnlineLocation; use crate::Result; use dprint::Dprint; use gh::Gh; +use gofumpt::Gofumpt; use shellcheck::ShellCheck; use shfmt::Shfmt; @@ -37,13 +39,14 @@ pub trait App { fn artifact_location(&self, version: &str, platform: Platform) -> Box; /// the name of the executable file in the archive - fn file_to_extract_from_archive(&self, version: &str, platform: Platform) -> String; + fn file_to_extract_from_archive(&self, version: &str, platform: Platform) -> Option; } pub fn all() -> Vec> { vec![ Box::new(Dprint {}), Box::new(Gh {}), + Box::new(Gofumpt {}), Box::new(ShellCheck {}), Box::new(Shfmt {}), ] diff --git a/src/apps/shellcheck.rs b/src/apps/shellcheck.rs index dfb1c4e9..32cc4cd1 100644 --- a/src/apps/shellcheck.rs +++ b/src/apps/shellcheck.rs @@ -36,8 +36,8 @@ impl App for ShellCheck { }) } - fn file_to_extract_from_archive(&self, _version: &str, platform: Platform) -> String { - S(self.executable(platform)) + fn file_to_extract_from_archive(&self, _version: &str, platform: Platform) -> Option { + Some(S(self.executable(platform))) } } diff --git a/src/apps/shfmt.rs b/src/apps/shfmt.rs index fd357bce..6b65149f 100644 --- a/src/apps/shfmt.rs +++ b/src/apps/shfmt.rs @@ -35,8 +35,8 @@ impl App for Shfmt { }) } - fn file_to_extract_from_archive(&self, _version: &str, _platform: Platform) -> String { - String::new() + fn file_to_extract_from_archive(&self, _version: &str, _platform: Platform) -> Option { + None } } diff --git a/src/archives/mod.rs b/src/archives/mod.rs index e2e4d4ee..d7fd75b5 100644 --- a/src/archives/mod.rs +++ b/src/archives/mod.rs @@ -27,13 +27,15 @@ pub trait Archive { /// extracts the given file in the given artifact to the given location on disk pub fn extract( artifact: Artifact, - path_in_archive: String, + path_in_archive: Option, path_on_disk: PathBuf, output: &dyn Output, ) -> Result { - for archive in all_archives() { - if archive.can_extract(&artifact.filename) { - return archive.extract(artifact.data, path_in_archive, path_on_disk, output); + if let Some(path_in_archive) = path_in_archive { + for archive in all_archives() { + if archive.can_extract(&artifact.filename) { + return archive.extract(artifact.data, path_in_archive, path_on_disk, output); + } } } // here the file doesn't match any of the known archives --> we assume its the binary itself From fa81e17b1586c61c39b84ec50ecbe8f8a80edf6a Mon Sep 17 00:00:00 2001 From: Kevin Goslar Date: Mon, 13 Nov 2023 10:06:16 -0600 Subject: [PATCH 4/8] gofumpt.rs --- src/apps/gofumpt.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/apps/gofumpt.rs b/src/apps/gofumpt.rs index 1c808d91..ab94ab04 100644 --- a/src/apps/gofumpt.rs +++ b/src/apps/gofumpt.rs @@ -22,7 +22,7 @@ impl App for Gofumpt { fn artifact_location(&self, version: &str, platform: Platform) -> Box { let filename = format!( - "gofumpt_v{version}_{os}_{cpu}", + "gofumpt_{version}_{os}_{cpu}", os = os_text(platform.os), cpu = cpu_text(platform.cpu), ); @@ -41,15 +41,15 @@ impl App for Gofumpt { fn os_text(os: Os) -> &'static str { match os { - Os::Windows => "pc-windows-msvc", - Os::Linux => "unknown-linux-gnu", - Os::MacOS => "apple-darwin", + Os::Windows => "windows", + Os::Linux => "linux", + Os::MacOS => "darwin", } } fn cpu_text(cpu: Cpu) -> &'static str { match cpu { - Cpu::Intel64 => "x86_64", - Cpu::Arm64 => "aarch64", + Cpu::Intel64 => "amd64", + Cpu::Arm64 => "arm64", } } From 1b377053adb3aae0f847825a8ff3737bb0a76216 Mon Sep 17 00:00:00 2001 From: Kevin Goslar Date: Mon, 13 Nov 2023 10:14:36 -0600 Subject: [PATCH 5/8] alphavet.rs mod.rs --- src/apps/alphavet.rs | 55 ++++++++++++++++++++++++++++++++++++++++++++ src/apps/mod.rs | 17 ++++++-------- 2 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 src/apps/alphavet.rs diff --git a/src/apps/alphavet.rs b/src/apps/alphavet.rs new file mode 100644 index 00000000..fd03df97 --- /dev/null +++ b/src/apps/alphavet.rs @@ -0,0 +1,55 @@ +use super::App; +use crate::detect::{Cpu, Os, Platform}; +use crate::hosting::{GithubReleaseAsset, OnlineLocation}; + +pub struct Alphavet {} + +impl App for Alphavet { + fn name(&self) -> &'static str { + "alphavet" + } + + fn executable(&self, platform: Platform) -> &'static str { + match platform.os { + Os::Windows => "alphavet.exe", + Os::Linux | Os::MacOS => "alphavet", + } + } + + fn homepage(&self) -> &'static str { + "https://github.com/skx/alphavet" + } + + fn artifact_location(&self, version: &str, platform: Platform) -> Box { + let filename = format!( + "alphavet-{os}-{cpu}", + os = os_text(platform.os), + cpu = cpu_text(platform.cpu), + ); + Box::new(GithubReleaseAsset { + organization: "skx", + repo: "alphavet", + version: version.to_string(), + filename, + }) + } + + fn file_to_extract_from_archive(&self, _version: &str, _platform: Platform) -> Option { + None + } +} + +fn os_text(os: Os) -> &'static str { + match os { + Os::Windows => "windows", + Os::Linux => "linux", + Os::MacOS => "darwin", + } +} + +fn cpu_text(cpu: Cpu) -> &'static str { + match cpu { + Cpu::Intel64 => "amd64", + Cpu::Arm64 => "arm64", + } +} diff --git a/src/apps/mod.rs b/src/apps/mod.rs index 38d3536b..1d0ecee5 100644 --- a/src/apps/mod.rs +++ b/src/apps/mod.rs @@ -1,5 +1,6 @@ //! all applications that run-this-app can run +mod alphavet; mod dprint; mod gh; mod gofumpt; @@ -10,11 +11,6 @@ use crate::detect::Platform; use crate::error::UserError; use crate::hosting::OnlineLocation; use crate::Result; -use dprint::Dprint; -use gh::Gh; -use gofumpt::Gofumpt; -use shellcheck::ShellCheck; -use shfmt::Shfmt; pub fn lookup(name: &str) -> Result> { for app in all() { @@ -44,10 +40,11 @@ pub trait App { pub fn all() -> Vec> { vec![ - Box::new(Dprint {}), - Box::new(Gh {}), - Box::new(Gofumpt {}), - Box::new(ShellCheck {}), - Box::new(Shfmt {}), + Box::new(alphavet::Alphavet {}), + Box::new(dprint::Dprint {}), + Box::new(gh::Gh {}), + Box::new(gofumpt::Gofumpt {}), + Box::new(shellcheck::ShellCheck {}), + Box::new(shfmt::Shfmt {}), ] } From f2f04b9b097607e5b8e8f38c0086d4fdb4afe4f7 Mon Sep 17 00:00:00 2001 From: Kevin Goslar Date: Mon, 13 Nov 2023 10:20:08 -0600 Subject: [PATCH 6/8] depth.rs mod.rs --- src/apps/depth.rs | 55 +++++++++++++++++++++++++++++++++++++++++++++++ src/apps/mod.rs | 2 ++ 2 files changed, 57 insertions(+) create mode 100644 src/apps/depth.rs diff --git a/src/apps/depth.rs b/src/apps/depth.rs new file mode 100644 index 00000000..4e2b82c4 --- /dev/null +++ b/src/apps/depth.rs @@ -0,0 +1,55 @@ +use super::App; +use crate::detect::{Cpu, Os, Platform}; +use crate::hosting::{GithubReleaseAsset, OnlineLocation}; + +pub struct Depth {} + +impl App for Depth { + fn name(&self) -> &'static str { + "depth" + } + + fn executable(&self, platform: Platform) -> &'static str { + match platform.os { + Os::Windows => "depth.exe", + Os::Linux | Os::MacOS => "depth", + } + } + + fn homepage(&self) -> &'static str { + "https://github.com/KyleBanks/depth" + } + + fn artifact_location(&self, version: &str, platform: Platform) -> Box { + let filename = format!( + "depth_{version}_{os}_{cpu}", + os = os_text(platform.os), + cpu = cpu_text(platform.cpu), + ); + Box::new(GithubReleaseAsset { + organization: "KyleBanks", + repo: "depth", + version: version.to_string(), + filename, + }) + } + + fn file_to_extract_from_archive(&self, _version: &str, _platform: Platform) -> Option { + None + } +} + +fn os_text(os: Os) -> &'static str { + match os { + Os::Windows => "windows", + Os::Linux => "linux", + Os::MacOS => "darwin", + } +} + +fn cpu_text(cpu: Cpu) -> &'static str { + match cpu { + Cpu::Intel64 => "amd64", + Cpu::Arm64 => "arm", + } +} diff --git a/src/apps/mod.rs b/src/apps/mod.rs index 1d0ecee5..8f0f2413 100644 --- a/src/apps/mod.rs +++ b/src/apps/mod.rs @@ -1,6 +1,7 @@ //! all applications that run-this-app can run mod alphavet; +mod depth; mod dprint; mod gh; mod gofumpt; @@ -41,6 +42,7 @@ pub trait App { pub fn all() -> Vec> { vec![ Box::new(alphavet::Alphavet {}), + Box::new(depth::Depth {}), Box::new(dprint::Dprint {}), Box::new(gh::Gh {}), Box::new(gofumpt::Gofumpt {}), From de20c008f04eb3e64ec80670ee10c72e22674089 Mon Sep 17 00:00:00 2001 From: Kevin Goslar Date: Mon, 13 Nov 2023 11:37:13 -0600 Subject: [PATCH 7/8] alphavet.rs depth.rs dprint.rs gh.rs gofumpt.rs golangci_lint.rs mod.rs shellcheck.rs shfmt.rs --- src/apps/alphavet.rs | 6 ++-- src/apps/depth.rs | 6 ++-- src/apps/dprint.rs | 4 +-- src/apps/gh.rs | 21 +++++++------ src/apps/gofumpt.rs | 4 +-- src/apps/golangci_lint.rs | 63 +++++++++++++++++++++++++++++++++++++++ src/apps/mod.rs | 2 ++ src/apps/shellcheck.rs | 6 ++-- src/apps/shfmt.rs | 6 ++-- 9 files changed, 93 insertions(+), 25 deletions(-) create mode 100644 src/apps/golangci_lint.rs diff --git a/src/apps/alphavet.rs b/src/apps/alphavet.rs index fd03df97..3aef52a9 100644 --- a/src/apps/alphavet.rs +++ b/src/apps/alphavet.rs @@ -29,7 +29,7 @@ impl App for Alphavet { Box::new(GithubReleaseAsset { organization: "skx", repo: "alphavet", - version: version.to_string(), + version: format!("v{version}"), filename, }) } @@ -41,15 +41,15 @@ impl App for Alphavet { fn os_text(os: Os) -> &'static str { match os { - Os::Windows => "windows", Os::Linux => "linux", Os::MacOS => "darwin", + Os::Windows => "windows", } } fn cpu_text(cpu: Cpu) -> &'static str { match cpu { - Cpu::Intel64 => "amd64", Cpu::Arm64 => "arm64", + Cpu::Intel64 => "amd64", } } diff --git a/src/apps/depth.rs b/src/apps/depth.rs index 4e2b82c4..eca069df 100644 --- a/src/apps/depth.rs +++ b/src/apps/depth.rs @@ -29,7 +29,7 @@ impl App for Depth { Box::new(GithubReleaseAsset { organization: "KyleBanks", repo: "depth", - version: version.to_string(), + version: format!("v{version}"), filename, }) } @@ -41,15 +41,15 @@ impl App for Depth { fn os_text(os: Os) -> &'static str { match os { - Os::Windows => "windows", Os::Linux => "linux", Os::MacOS => "darwin", + Os::Windows => "windows", } } fn cpu_text(cpu: Cpu) -> &'static str { match cpu { - Cpu::Intel64 => "amd64", Cpu::Arm64 => "arm", + Cpu::Intel64 => "amd64", } } diff --git a/src/apps/dprint.rs b/src/apps/dprint.rs index f716472b..d1f93d6e 100644 --- a/src/apps/dprint.rs +++ b/src/apps/dprint.rs @@ -42,15 +42,15 @@ impl App for Dprint { fn os_text(os: Os) -> &'static str { match os { - Os::Windows => "pc-windows-msvc", Os::Linux => "unknown-linux-gnu", Os::MacOS => "apple-darwin", + Os::Windows => "pc-windows-msvc", } } fn cpu_text(cpu: Cpu) -> &'static str { match cpu { - Cpu::Intel64 => "x86_64", Cpu::Arm64 => "aarch64", + Cpu::Intel64 => "x86_64", } } diff --git a/src/apps/gh.rs b/src/apps/gh.rs index f9d54f94..9c5e7a6a 100644 --- a/src/apps/gh.rs +++ b/src/apps/gh.rs @@ -1,7 +1,6 @@ use super::App; use crate::detect::{Cpu, Os, Platform}; use crate::hosting::{GithubReleaseAsset, OnlineLocation}; -use big_s::S; pub struct Gh {} @@ -29,36 +28,40 @@ impl App for Gh { ext = ext_text(platform.os) ); Box::new(GithubReleaseAsset { - organization: "dprint", - repo: "dprint", - version: version.to_string(), + organization: "cli", + repo: "cli", + version: format!("v{version}"), filename, }) } - fn file_to_extract_from_archive(&self, _version: &str, platform: Platform) -> Option { - Some(S(self.executable(platform))) + fn file_to_extract_from_archive( + &self, + version: &str, + Platform { os, cpu }: Platform, + ) -> Option { + Some(format!("gh_{version}_{os}_{cpu}/bin/gh",)) } } fn os_text(os: Os) -> &'static str { match os { - Os::Windows => "windows", Os::Linux => "linux", Os::MacOS => "macOS", + Os::Windows => "windows", } } fn cpu_text(cpu: Cpu) -> &'static str { match cpu { - Cpu::Intel64 => "amd64", Cpu::Arm64 => "arm64", + Cpu::Intel64 => "amd64", } } fn ext_text(os: Os) -> &'static str { match os { - Os::Windows | Os::MacOS => "zip", Os::Linux => "tgz", + Os::Windows | Os::MacOS => "zip", } } diff --git a/src/apps/gofumpt.rs b/src/apps/gofumpt.rs index ab94ab04..a349ccec 100644 --- a/src/apps/gofumpt.rs +++ b/src/apps/gofumpt.rs @@ -41,15 +41,15 @@ impl App for Gofumpt { fn os_text(os: Os) -> &'static str { match os { - Os::Windows => "windows", Os::Linux => "linux", Os::MacOS => "darwin", + Os::Windows => "windows", } } fn cpu_text(cpu: Cpu) -> &'static str { match cpu { - Cpu::Intel64 => "amd64", Cpu::Arm64 => "arm64", + Cpu::Intel64 => "amd64", } } diff --git a/src/apps/golangci_lint.rs b/src/apps/golangci_lint.rs new file mode 100644 index 00000000..d7b0ff6a --- /dev/null +++ b/src/apps/golangci_lint.rs @@ -0,0 +1,63 @@ +use super::App; +use crate::detect::{Cpu, Os, Platform}; +use crate::hosting::{GithubReleaseAsset, OnlineLocation}; + +pub struct GolangCiLint {} + +impl App for GolangCiLint { + fn name(&self) -> &'static str { + "golangci-lint" + } + + fn executable(&self, platform: Platform) -> &'static str { + match platform.os { + Os::Windows => "golangci-lint.exe", + Os::Linux | Os::MacOS => "golangci-lint", + } + } + + fn homepage(&self) -> &'static str { + "https://github.com/golangci/golangci-lint" + } + + fn artifact_location(&self, version: &str, platform: Platform) -> Box { + let filename = format!( + "golangci-lint-v{version}-{os}-{cpu}.{ext}", + os = os_text(platform.os), + cpu = cpu_text(platform.cpu), + ext = ext_text(platform.os), + ); + Box::new(GithubReleaseAsset { + organization: "golangci", + repo: "golangci-lint", + version: format!("v{version}"), + filename, + }) + } + + fn file_to_extract_from_archive(&self, _version: &str, _platform: Platform) -> Option { + None + } +} + +fn os_text(os: Os) -> &'static str { + match os { + Os::Linux => "linux", + Os::MacOS => "darwin", + Os::Windows => "windows", + } +} + +fn cpu_text(cpu: Cpu) -> &'static str { + match cpu { + Cpu::Arm64 => "arm64", + Cpu::Intel64 => "amd64", + } +} + +fn ext_text(os: Os) -> &'static str { + match os { + Os::Linux | Os::MacOS => "tar.gz", + Os::Windows => "zip", + } +} diff --git a/src/apps/mod.rs b/src/apps/mod.rs index 8f0f2413..25421f7b 100644 --- a/src/apps/mod.rs +++ b/src/apps/mod.rs @@ -5,6 +5,7 @@ mod depth; mod dprint; mod gh; mod gofumpt; +mod golangci_lint; mod shellcheck; mod shfmt; @@ -46,6 +47,7 @@ pub fn all() -> Vec> { Box::new(dprint::Dprint {}), Box::new(gh::Gh {}), Box::new(gofumpt::Gofumpt {}), + Box::new(golangci_lint::GolangCiLint {}), Box::new(shellcheck::ShellCheck {}), Box::new(shfmt::Shfmt {}), ] diff --git a/src/apps/shellcheck.rs b/src/apps/shellcheck.rs index 32cc4cd1..dd3f7404 100644 --- a/src/apps/shellcheck.rs +++ b/src/apps/shellcheck.rs @@ -43,22 +43,22 @@ impl App for ShellCheck { fn os_text(os: Os) -> &'static str { match os { - Os::Windows => "windows", Os::Linux => "linux", Os::MacOS => "darwin", + Os::Windows => "windows", } } fn cpu_text(cpu: Cpu) -> &'static str { match cpu { - Cpu::Intel64 => "x86_64", Cpu::Arm64 => "aarch64", + Cpu::Intel64 => "x86_64", } } fn ext_text(os: Os) -> &'static str { match os { - Os::Windows => "zip", Os::Linux | Os::MacOS => "tar.gz", + Os::Windows => "zip", } } diff --git a/src/apps/shfmt.rs b/src/apps/shfmt.rs index 6b65149f..ce058701 100644 --- a/src/apps/shfmt.rs +++ b/src/apps/shfmt.rs @@ -42,22 +42,22 @@ impl App for Shfmt { fn os_text(os: Os) -> &'static str { match os { - Os::Windows => "windows", Os::Linux => "linux", Os::MacOS => "darwin", + Os::Windows => "windows", } } fn cpu_text(cpu: Cpu) -> &'static str { match cpu { - Cpu::Intel64 => "amd64", Cpu::Arm64 => "arm64", + Cpu::Intel64 => "amd64", } } fn ext_text(os: Os) -> &'static str { match os { - Os::Windows => ".exe", Os::Linux | Os::MacOS => "", + Os::Windows => ".exe", } } From a8c70504cc0ec621628efa962c0b85f0791f9222 Mon Sep 17 00:00:00 2001 From: Kevin Goslar Date: Mon, 13 Nov 2023 11:43:49 -0600 Subject: [PATCH 8/8] mod.rs scc.rs --- src/apps/mod.rs | 2 ++ src/apps/scc.rs | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 src/apps/scc.rs diff --git a/src/apps/mod.rs b/src/apps/mod.rs index 25421f7b..437d241a 100644 --- a/src/apps/mod.rs +++ b/src/apps/mod.rs @@ -6,6 +6,7 @@ mod dprint; mod gh; mod gofumpt; mod golangci_lint; +mod scc; mod shellcheck; mod shfmt; @@ -48,6 +49,7 @@ pub fn all() -> Vec> { Box::new(gh::Gh {}), Box::new(gofumpt::Gofumpt {}), Box::new(golangci_lint::GolangCiLint {}), + Box::new(scc::Scc {}), Box::new(shellcheck::ShellCheck {}), Box::new(shfmt::Shfmt {}), ] diff --git a/src/apps/scc.rs b/src/apps/scc.rs new file mode 100644 index 00000000..6148e8d3 --- /dev/null +++ b/src/apps/scc.rs @@ -0,0 +1,62 @@ +use big_s::S; + +use super::App; +use crate::detect::{Cpu, Os, Platform}; +use crate::hosting::{GithubReleaseAsset, OnlineLocation}; + +pub struct Scc {} + +impl App for Scc { + fn name(&self) -> &'static str { + "scc" + } + + fn executable(&self, platform: Platform) -> &'static str { + match platform.os { + Os::Windows => "scc.exe", + Os::Linux | Os::MacOS => "scc", + } + } + + fn homepage(&self) -> &'static str { + "https://github.com/boyter/scc" + } + + fn artifact_location(&self, version: &str, platform: Platform) -> Box { + let filename = format!( + "scc_{version}_{os}_{cpu}.{ext}", + os = os_text(platform.os), + cpu = cpu_text(platform.cpu), + ext = ext_text(platform.os) + ); + Box::new(GithubReleaseAsset { + organization: "boyter", + repo: "scc", + version: format!("v{version}"), + filename, + }) + } + + fn file_to_extract_from_archive(&self, _version: &str, platform: Platform) -> Option { + Some(S(self.executable(platform))) + } +} + +fn os_text(os: Os) -> &'static str { + match os { + Os::Linux => "Linux", + Os::MacOS => "Darwin", + Os::Windows => "Windows", + } +} + +fn cpu_text(cpu: Cpu) -> &'static str { + match cpu { + Cpu::Arm64 => "arm64", + Cpu::Intel64 => "x86_64", + } +} + +fn ext_text(_os: Os) -> &'static str { + "tar.gz" +}