Skip to content

Commit 5942b23

Browse files
authored
Merge pull request #124 from WillAbides/current-system
"current" system
2 parents 4fad0a2 + c0f5d1b commit 5942b23

File tree

3 files changed

+60
-46
lines changed

3 files changed

+60
-46
lines changed

cmd/bindown/completion.go

+7-46
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"context"
5+
_ "embed"
56
"os"
67
"runtime"
78
"sort"
@@ -12,6 +13,11 @@ import (
1213
"github.com/willabides/bindown/v3"
1314
)
1415

16+
//go:generate sh -c "go tool dist list > go_dist_list.txt"
17+
18+
//go:embed go_dist_list.txt
19+
var goDists string
20+
1521
func findConfigFileForCompletion(args []string) string {
1622
for i, arg := range args {
1723
if len(args) == i+1 {
@@ -184,50 +190,5 @@ func systemCompleter(ctx context.Context) complete.PredictFunc {
184190
}
185191

186192
var allSystemsCompleter = complete.PredictFunc(func(a complete.Args) []string {
187-
return strings.Split(goDists, "\n")
193+
return append([]string{"current"}, strings.Split(goDists, "\n")...)
188194
})
189-
190-
// from `go tool dist list`
191-
const goDists = `aix/ppc64
192-
android/386
193-
android/amd64
194-
android/arm
195-
android/arm64
196-
darwin/386
197-
darwin/amd64
198-
darwin/arm
199-
darwin/arm64
200-
dragonfly/amd64
201-
freebsd/386
202-
freebsd/amd64
203-
freebsd/arm
204-
freebsd/arm64
205-
illumos/amd64
206-
js/wasm
207-
linux/386
208-
linux/amd64
209-
linux/arm
210-
linux/arm64
211-
linux/mips
212-
linux/mips64
213-
linux/mips64le
214-
linux/mipsle
215-
linux/ppc64
216-
linux/ppc64le
217-
linux/riscv64
218-
linux/s390x
219-
netbsd/386
220-
netbsd/amd64
221-
netbsd/arm
222-
netbsd/arm64
223-
openbsd/386
224-
openbsd/amd64
225-
openbsd/arm
226-
openbsd/arm64
227-
plan9/386
228-
plan9/amd64
229-
plan9/arm
230-
solaris/amd64
231-
windows/386
232-
windows/amd64
233-
windows/arm`

cmd/bindown/go_dist_list.txt

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
aix/ppc64
2+
android/386
3+
android/amd64
4+
android/arm
5+
android/arm64
6+
darwin/amd64
7+
darwin/arm64
8+
dragonfly/amd64
9+
freebsd/386
10+
freebsd/amd64
11+
freebsd/arm
12+
freebsd/arm64
13+
freebsd/riscv64
14+
illumos/amd64
15+
ios/amd64
16+
ios/arm64
17+
js/wasm
18+
linux/386
19+
linux/amd64
20+
linux/arm
21+
linux/arm64
22+
linux/loong64
23+
linux/mips
24+
linux/mips64
25+
linux/mips64le
26+
linux/mipsle
27+
linux/ppc64
28+
linux/ppc64le
29+
linux/riscv64
30+
linux/s390x
31+
netbsd/386
32+
netbsd/amd64
33+
netbsd/arm
34+
netbsd/arm64
35+
openbsd/386
36+
openbsd/amd64
37+
openbsd/arm
38+
openbsd/arm64
39+
openbsd/mips64
40+
plan9/386
41+
plan9/amd64
42+
plan9/arm
43+
solaris/amd64
44+
windows/386
45+
windows/amd64
46+
windows/arm
47+
windows/arm64

systems.go

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package bindown
33
import (
44
"bytes"
55
"fmt"
6+
"runtime"
67
)
78

89
// SystemInfo contains os and architecture for a target system
@@ -24,6 +25,11 @@ func (s *SystemInfo) String() string {
2425

2526
// UnmarshalText implements encoding.TextUnmarshaler
2627
func (s *SystemInfo) UnmarshalText(text []byte) error {
28+
if string(text) == "current" {
29+
s.OS = runtime.GOOS
30+
s.Arch = runtime.GOARCH
31+
return nil
32+
}
2733
parts := bytes.Split(text, []byte{'/'})
2834
if len(parts) != 2 {
2935
return fmt.Errorf(`systemInfo must be in the form "os/architecture"`)

0 commit comments

Comments
 (0)