From 61e655e0a6260d653c9cb607cf5657198fcb1ee0 Mon Sep 17 00:00:00 2001 From: Engin Diri Date: Wed, 21 Feb 2024 21:35:52 +0100 Subject: [PATCH] feat: add gptscript as cli feat: add gptscript as cli Signed-off-by: Engin Diri --- README.md | 1 + pkg/get/get_test.go | 50 +++++++++++++++++++++++++++++++++++++++++++++ pkg/get/tools.go | 36 ++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) diff --git a/README.md b/README.md index d78170869..e8299bcc0 100644 --- a/README.md +++ b/README.md @@ -802,6 +802,7 @@ There are 56 apps that you can install on your cluster. | [golangci-lint](https://github.com/golangci/golangci-lint) | Go linters aggregator. | | [gomplate](https://github.com/hairyhenderson/gomplate) | A flexible commandline tool for template rendering. Supports lots of local and remote datasources. | | [goreleaser](https://github.com/goreleaser/goreleaser) | Deliver Go binaries as fast and easily as possible | +| [gptscript](https://github.com/gptscript-ai/gptscript) | Natural Language Programming | | [grafana-agent](https://github.com/grafana/agent) | Grafana Agent is a telemetry collector for sending metrics, logs, and trace data to the opinionated Grafana observability stack. | | [grype](https://github.com/anchore/grype) | A vulnerability scanner for container images and filesystems | | [hadolint](https://github.com/hadolint/hadolint) | A smarter Dockerfile linter that helps you build best practice Docker images | diff --git a/pkg/get/get_test.go b/pkg/get/get_test.go index 3343234ce..37dd67916 100644 --- a/pkg/get/get_test.go +++ b/pkg/get/get_test.go @@ -6933,3 +6933,53 @@ func Test_DownloadCloudHypervisorRemote(t *testing.T) { } } } + +func Test_DownloadGPTScript(t *testing.T) { + tools := MakeTools() + name := "gptscript" + const version = "0.1.1" + + tool := getTool(name, tools) + + tests := []test{ + { + os: "ming", + arch: arch64bit, + version: version, + url: `https://github.com/gptscript-ai/gptscript/releases/download/0.1.1/gptscript-0.1.1-windows-amd64.zip`, + }, + { + os: "linux", + arch: arch64bit, + version: version, + url: `https://github.com/gptscript-ai/gptscript/releases/download/0.1.1/gptscript-0.1.1-linux-amd64.tar.gz`, + }, + { + os: "linux", + arch: archARM64, + version: version, + url: `https://github.com/gptscript-ai/gptscript/releases/download/0.1.1/gptscript-0.1.1-linux-arm64.tar.gz`, + }, + { + os: "darwin", + arch: arch64bit, + version: version, + url: `https://github.com/gptscript-ai/gptscript/releases/download/0.1.1/gptscript-0.1.1-macOS-universal.tar.gz`, + }, + { + os: "darwin", + arch: archDarwinARM64, + version: version, + url: `https://github.com/gptscript-ai/gptscript/releases/download/0.1.1/gptscript-0.1.1-macOS-universal.tar.gz`, + }, + } + for _, tc := range tests { + got, err := tool.GetURL(tc.os, tc.arch, tc.version, false) + if err != nil { + t.Fatal(err) + } + if got != tc.url { + t.Errorf("want: %s, got: %s", tc.url, got) + } + } +} diff --git a/pkg/get/tools.go b/pkg/get/tools.go index 89a6e2a65..c28aacb59 100644 --- a/pkg/get/tools.go +++ b/pkg/get/tools.go @@ -3993,5 +3993,41 @@ https://github.com/{{.Owner}}/{{.Repo}}/releases/download/{{.Version}}/{{.Repo}} ch-remote-static{{$ext}}`, }) + + tools = append(tools, + Tool{ + Owner: "gptscript-ai", + Repo: "gptscript", + Name: "gptscript", + Description: "Natural Language Programming", + BinaryTemplate: ` + {{ $os := .OS }} + {{ $arch := .Arch }} + {{ $ext := "tar.gz" }} + + {{- if eq .Arch "aarch64" -}} + {{$arch = "arm64"}} + {{- else if eq .Arch "arm64" -}} + {{ $arch = "arm64" }} + {{- else if eq .Arch "x86_64" -}} + {{ $arch = "amd64" }} + {{- end -}} + + {{ if HasPrefix .OS "ming" -}} + {{$os = "windows"}} + {{$ext = "zip"}} + {{- end -}} + + {{- if eq .OS "darwin" -}} + {{$os = "macOS"}} + {{ $arch = "universal" }} + {{- else if eq .OS "linux" -}} + {{ $os = "linux" }} + {{- end -}} + + + gptscript-{{.Version}}-{{$os}}-{{$arch}}.{{$ext}} + `, + }) return tools }