Bob
Usage
I use it in combination with direnv to build golang programs and copy them to a raspberry pi. It also offers functionality to intialize the binary as a service and do other setup data.
Build it locally for your local machine and for the raspberry. The env vars are defined in the .envrc
.
# Build for local machine
go build -o "${BASE_DIR}/build/bob" "${BASE_DIR}/main.go" &&
chmod +x "${BASE_DIR}/build/bob"
# Build for predefined os/arch
env GOOS="$DEVICE_OS" GOARCH="$DEVICE_ARCH" go build -o "${BASE_DIR}/build/bob-${DEVICE_OS}-${DEVICE_ARCH}" "${BASE_DIR}/main.go" &&
chmod +x "${BASE_DIR}/build/bob-${DEVICE_OS}-${DEVICE_ARCH}"
Copy it to your <SERVICE> / or add it to your path:
rm -rf "../<SERVICE>/bin/bob"
cp "${BASE_DIR}/build/bob" "../<SERVICE>/bin/bob"
scp "${BASE_DIR}/build/bob-${DEVICE_OS}-${DEVICE_ARCH}" "${DEVICE_USER}"@"${DEVICE_NAME}":"${DEVICE_ROOT}/<SERVICE>/bin/bob"
Here is the bob --help
output:
Bob is a simple command line helper tool to build go applications for the raspberry.
You can locally use it or with a CI pipeline, configure it via .bob.yaml file in your project root.
Usage:
bob [command]
Available Commands:
build Execute the commands configured in .bob.yaml > commands.build
completion Generate the autocompletion script for the specified shell
copy Execute the commands configured in .bob.yaml > commands.copy
help Help about any command
init Execute the commands configured in .bob.yaml > commands.init
Flags:
--config string config file (default is /Users/hans/go/src/gitlab.void-ptr.org/go/bob/.bob.yaml)
-d, --debug execute debug version
-e, --env string Environment to run under (default "development")
-h, --help help for bob
Use "bob [command] --help" for more information about a command.
The config is read from the path ${BASE_DIR}/.bob.yaml
, you can use direnv to set ${BASE_DIR}
.
It looks like this (or this):
version: "0.1.0"
commands:
build:
development:
run:
- echo "implement dev build!"
copy:
development:
run:
- echo "implement dev copy!"
init:
development:
run:
- echo "implement dev init!"
Development
This is a simple cobra / viper application located in pkg/cmd.