Skip to content

Commit 36cd1cf

Browse files
authored
fix: add argsh binary (#5)
https://github.com/arg-sh/argsh
1 parent a2a4663 commit 36cd1cf

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ The `Binary` struct represents a binary file, including its name, file path, ver
9898

9999
```go
100100
bin := binary.Binary{Name: "mybinary", Version: "1.0.0"}
101-
bin.EnsureBinary(true, false)
101+
bin.EnsureBinary(true)
102102
```
103103

104104
Have a look into [pkg/binary](./pkg/binary/) for more details.

cmd/b/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77

88
"github.com/buyoio/b/pkg/binaries"
9+
"github.com/buyoio/b/pkg/binaries/argsh"
910
"github.com/buyoio/b/pkg/binaries/hcloud"
1011
"github.com/buyoio/b/pkg/binaries/jq"
1112
"github.com/buyoio/b/pkg/binaries/k9s"
@@ -41,6 +42,7 @@ func main() {
4142
mkcert.Binary(o),
4243
tilt.Binary(o),
4344
yq.Binary(o),
45+
argsh.Binary(o),
4446
},
4547
IO: &streams.IO{
4648
In: os.Stdin,

pkg/binaries/argsh/argsh.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package argsh
2+
3+
import (
4+
"context"
5+
"strings"
6+
7+
"github.com/buyoio/b/pkg/binaries"
8+
"github.com/buyoio/b/pkg/binary"
9+
)
10+
11+
func Binary(options *binaries.BinaryOptions) *binary.Binary {
12+
if options == nil {
13+
options = &binaries.BinaryOptions{
14+
Context: context.Background(),
15+
}
16+
}
17+
return &binary.Binary{
18+
Context: options.Context,
19+
Envs: options.Envs,
20+
Tracker: options.Tracker,
21+
Version: options.Version,
22+
Name: "argsh",
23+
GitHubRepo: "arg-sh/argsh",
24+
GitHubFile: "argsh",
25+
VersionF: binary.GithubLatest,
26+
VersionLocalF: func(b *binary.Binary) (string, error) {
27+
s, err := b.Exec("version")
28+
if err != nil {
29+
return "", err
30+
}
31+
v := strings.Split(s, " ")
32+
return v[len(v)-1], nil
33+
},
34+
}
35+
}

0 commit comments

Comments
 (0)