Skip to content
/ b Public
forked from fentas/b

๐Ÿง™โ€โ™‚๏ธ b is your one stop binary manager.

License

Notifications You must be signed in to change notification settings

ferenc-zagon/b

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

51 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

b

Stargazers Releases Issues

ย 

`b` is binary or a go package that provides a set of utilities for managing and executing binary files. It is particularly useful for binaries hosted on GitHub.

The package includes a Binary struct that represents a binary file, including its name, file path, version, and other related properties. You can create a Binary struct by providing the binary name and version, and then use the EnsureBinary method to ensure that the binary is available on the system.

ย 

๐Ÿพ How to use b as binary

# List all installed binaries and/or defined in b.yaml
b --all

# Print as JSON
b -ao json

# Install all binaries defined in b.yaml
b -a --install

# Install or update jq
b -iu jq

# Force install jq, overwriting existing binary
b -fi jq

# Upgrade all binaries
b -aiu

# List all available binaries
b --list

# Checks (silent) if all binaries are up to date
b -acq || echo "Some binaries are not up to date"

ย 

๐Ÿงพ Configuration, what to install

b needs one of three things defined to know where to install binaries to:

  • PATH_BIN env, set to the directory where you want to install binaries.
  • PATH_BASE env, set to the project root directory. All binaries will be installed in the .bin directory.
  • If you are in a git repository, b will install binaries in the .bin directory in the root of the repository.

If none of these are set, b will fail.

To properly use the --all flag, you should create a b.yaml file in the binary directory. This file should contain a list of binaries you want to manage. Here is an example:

jq:
  version: 1.7
kind:
tilt:

This will ensure that jq, kind, and tilt are installed and at the correct version. If you don't specify a version, b will install the latest version.

ย 

๐Ÿ—๏ธ Manuell build

If you have Go installed, you can build and install the latest version of b with:

go install github.com/fentas/b/b@latest

Binaries built in this way do not have the correct version embedded. Use our prebuilt binaries or check out .goreleaser.yaml to learn how to embed it yourself.

ย 

๐Ÿ“š How to use b as go import

To use this package, you need to import it in your Go project:

import "github.com/fentas/b/pkg/binary"

The Binary struct represents a binary file, including its name, file path, version, and other related properties. You can create a Binary struct by providing the binary name and version:

bin := binary.Binary{Name: "mybinary", Version: "1.0.0"}
bin.EnsureBinary(true)

Have a look into pkg/binary for more details.

ย 

๐Ÿ“ฆ Prepackaged Binaries

Have a look into pkg/binaries for prepackaged binaries.

  • argsh - Utilities for Bash script quality
  • b - (Selfupdate) Manage and execute binary files
  • clusterctl - Kubernetes cluster lifecycle management
  • docker-compose - Define and run multi-container Docker applications
  • gh - GitHub CLI wrapper
  • hcloud - Hetzner Cloud CLI wrapper
  • jq - Command-line JSON processor
  • k9s - Kubernetes CLI to manage your clusters
  • kind - Kubernetes IN Docker
  • kubectl - Kubernetes CLI to manage your clusters
  • kubeseal - A Kubernetes controller and tool for one-way encrypted Secrets
  • kustomize - Kubernetes native configuration management
  • mkcert - Create locally-trusted development certificates
  • packer - Packer is a tool for creating machine and container images
  • sops - Secure processing of configuration files
  • stern - Simultaneous log tailing for multiple Kubernetes pods and containers
  • tilt - Local Kubernetes development with no stress
  • yq - Command-line YAML processor

Feel free to extend this, PRs are welcome.

ย 

๐Ÿง™โ€โ™‚๏ธ Magic, use direnv

Using direnv allows you to load required binaries bound to a specific project.

#!/usr/bin/env bash
set -euo pipefail

: "${PATH_BASE:="$(git rev-parse --show-toplevel)"}"
: "${PATH_BIN:="${PATH_BASE}/.bin"}"
export PATH_BASE PATH_BIN

This is all you need or have a look here.

ย 

๐ŸŽฏ Short term goals

  • Recognize the operating system and architecture and offer the correct binary
  • Enforce min and max versions
  • Create a logo
  • Docs
  • Tests

ย 

๐Ÿ“œ License

b is released under the MIT license, which grants the following permissions:

  • Commercial use
  • Distribution
  • Modification
  • Private use

For more convoluted language, see the LICENSE. Let's build a better Bash experience together.

ย 

โค๏ธ Gratitude

Thanks to all tools and projects that developing this project made possible.

ย 

Copyright ยฉ 2024-present Fentas

About

๐Ÿง™โ€โ™‚๏ธ b is your one stop binary manager.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 95.8%
  • Shell 4.2%