Skip to content

Commit

Permalink
feat: add gh (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
fentas committed Apr 3, 2024
1 parent 4541d26 commit 6a9d2e0
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 10 deletions.
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 @@ import (

"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 @@ func main() {
}
root := cli.NewCmdBinary(&cli.CmdBinaryOptions{
Binaries: []*binary.Binary{
argsh.Binary(o),
gh.Binary(o),
hcloud.Binary(o),
jq.Binary(o),
k9s.Binary(o),
Expand All @@ -42,7 +45,6 @@ func main() {
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(),
}
}
return &binary.Binary{
Context: options.Context,
Envs: options.Envs,
Tracker: options.Tracker,
Version: options.Version,
GitHubRepo: "cli/cli",
// 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
},
Name: "gh",
VersionF: binary.GithubLatest,
IsTarGz: true,
VersionLocalF: func(b *binary.Binary) (string, error) {
v, err := b.Exec("version")
if err != nil {
return "", err
}
s := strings.Split(v, "/")
return s[len(s)-1], nil
},
}
}
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 @@ package cli
import (
"fmt"
"sync"
"time"

"github.com/buyoio/goodies/progress"

Expand Down Expand Up @@ -68,5 +69,7 @@ func (o *CmdBinaryOptions) installBinaries() error {
}
}
wg.Wait()
// let the progress bar render
time.Sleep(200 * time.Millisecond)
return nil
}

0 comments on commit 6a9d2e0

Please sign in to comment.