Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add gh #7

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,16 @@ Have a look into [pkg/binary](./pkg/binary/) for more details.

Have a look into [pkg/binaries](./pkg/binaries/) for prepackaged binaries.

- `argsh` - Utilities for Bash script quality
- `hcloud` - Hetzner Cloud CLI
- `jq` - Command-line JSON processor
- `k9s` - Kubernetes CLI to manage your clusters
- `kind` - Kubernetes IN Docker
- `kubectl` - Kubernetes CLI to manage your clusters
- `mkcert` - Create locally-trusted development certificates
- `tilt` - Local Kubernetes development with no stress
- `yq` - Command-line YAML processor
- [argsh](https://github.com/arg-sh/argsh) - Utilities for Bash script quality
- [gh](https://github.com/cli/cli) - GitHub CLI wrapper
- [hcloud](https://github.com/hetznercloud/cli) - Hetzner Cloud CLI wrapper
- [jq](https://github.com/jqlang/jq) - Command-line JSON processor
- [k9s](https://github.com/derailed/k9s) - Kubernetes CLI to manage your clusters
- [kind](https://github.com/kubernetes-sigs/kind) - Kubernetes IN Docker
- [kubectl](https://github.com/kubernetes/kubectl) - Kubernetes CLI to manage your clusters
- [mkcert](https://github.com/FiloSottile/mkcert) - Create locally-trusted development certificates
- [tilt](https://github.com/tilt-dev/tilt) - Local Kubernetes development with no stress
- [yq](https://github.com/mikefarah/yq) - Command-line YAML processor

Feel free to extend this, PRs are welcome.

Expand Down
4 changes: 3 additions & 1 deletion cmd/b/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

"github.com/buyoio/b/pkg/binaries"
"github.com/buyoio/b/pkg/binaries/argsh"
"github.com/buyoio/b/pkg/binaries/gh"
"github.com/buyoio/b/pkg/binaries/hcloud"
"github.com/buyoio/b/pkg/binaries/jq"
"github.com/buyoio/b/pkg/binaries/k9s"
Expand Down Expand Up @@ -34,6 +35,8 @@
}
root := cli.NewCmdBinary(&cli.CmdBinaryOptions{
Binaries: []*binary.Binary{
argsh.Binary(o),
gh.Binary(o),

Check warning on line 39 in cmd/b/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/b/main.go#L38-L39

Added lines #L38 - L39 were not covered by tests
hcloud.Binary(o),
jq.Binary(o),
k9s.Binary(o),
Expand All @@ -42,7 +45,6 @@
mkcert.Binary(o),
tilt.Binary(o),
yq.Binary(o),
argsh.Binary(o),
},
IO: &streams.IO{
In: os.Stdin,
Expand Down
45 changes: 45 additions & 0 deletions pkg/binaries/gh/gh.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package gh

import (
"context"
"fmt"
"runtime"
"strings"

"github.com/buyoio/b/pkg/binaries"
"github.com/buyoio/b/pkg/binary"
)

func Binary(options *binaries.BinaryOptions) *binary.Binary {
if options == nil {
options = &binaries.BinaryOptions{
Context: context.Background(),

Check warning on line 16 in pkg/binaries/gh/gh.go

View check run for this annotation

Codecov / codecov/patch

pkg/binaries/gh/gh.go#L13-L16

Added lines #L13 - L16 were not covered by tests
}
}
return &binary.Binary{
Context: options.Context,
Envs: options.Envs,
Tracker: options.Tracker,
Version: options.Version,
GitHubRepo: "cli/cli",

Check warning on line 24 in pkg/binaries/gh/gh.go

View check run for this annotation

Codecov / codecov/patch

pkg/binaries/gh/gh.go#L19-L24

Added lines #L19 - L24 were not covered by tests
// https://github.com/cli/cli/releases/download/v2.46.0/gh_2.46.0_linux_amd64.tar.gz
GitHubFileF: func(b *binary.Binary) (string, error) {
return fmt.Sprintf("gh_%s_%s_%s.tar.gz",
b.Version[1:],
runtime.GOOS,
runtime.GOARCH,
), nil
},

Check warning on line 32 in pkg/binaries/gh/gh.go

View check run for this annotation

Codecov / codecov/patch

pkg/binaries/gh/gh.go#L26-L32

Added lines #L26 - L32 were not covered by tests
Name: "gh",
VersionF: binary.GithubLatest,
IsTarGz: true,
VersionLocalF: func(b *binary.Binary) (string, error) {
v, err := b.Exec("version")
if err != nil {
return "", err

Check warning on line 39 in pkg/binaries/gh/gh.go

View check run for this annotation

Codecov / codecov/patch

pkg/binaries/gh/gh.go#L36-L39

Added lines #L36 - L39 were not covered by tests
}
s := strings.Split(v, "/")
return s[len(s)-1], nil

Check warning on line 42 in pkg/binaries/gh/gh.go

View check run for this annotation

Codecov / codecov/patch

pkg/binaries/gh/gh.go#L41-L42

Added lines #L41 - L42 were not covered by tests
},
}
}
3 changes: 3 additions & 0 deletions pkg/cli/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import (
"fmt"
"sync"
"time"

"github.com/buyoio/goodies/progress"

Expand Down Expand Up @@ -68,5 +69,7 @@
}
}
wg.Wait()
// let the progress bar render
time.Sleep(200 * time.Millisecond)

Check warning on line 73 in pkg/cli/helper.go

View check run for this annotation

Codecov / codecov/patch

pkg/cli/helper.go#L73

Added line #L73 was not covered by tests
return nil
}