github.com/leep-frog/command
is a Go package for writing custom bash commands in Go! Some of the most valuable benefits of this package include:
See the following docs folders for more info:
-
docs/basics
folder: Core concepts and types for this package. -
docs/features
folder: Exhaustive list of features.
-
Create a new go project (
go mod init
) -
Include this library in the project (
go get github.com/leep-frog/command
) -
Create a
main.go
with the following contents:
package main
import (
"os"
"github.com/leep-frog/command/sourcerer"
)
func main() {
clis := []sourcerer.CLI{
// Put the CLIs you want here
}
opts := []sourcerer.Option{
// Put CLI options (e.g. Aliasers) here
}
os.Exit(sourcerer.Source("myCLI", clis, opts...))
}
cd
into your project, run the following onetime setup, and follow the instructions provided in the output:
go run . source myCLIs $OUTPUT_FOLDER
There are a couple of ways to get started. Some people love reading through a good doc, while others prefer to get their hands on examples right away. The following two sub-sections should hopefully satiate both of those approaches.
The steps from the Installation section will create a new bash
CLI called sourcerer
. You can use this command to generate entirely new bash
CLIs written completely in Go!
To get an idea of how to write your own commands, start with an example:
-
Download the example_main.go file locally and read through the file to become familiar with CLI setup (the file is thoroughly commented).
-
cd
into the local directory containing theexample_main.go
file. -
Run
sourcerer . my_custom_clis
(and add this line to your bash profile to automatically load this command from now on).
You are now able to use the mfc
command in your bash shell! Try out the following runs and see what happens:
-
mfc
-
mfc $USER
-
mfc <tab><tab>
-
mfc B<tab><tab>
-
mfc Br<tab>
-
mfc there 10
-
mfc World -f 10
To explore a more thorough explanation of all this package can do,
check out the docs/features
folder