Skip to content

leep-frog/command

Repository files navigation

Command

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:

Installation

  1. Create a new go project (go mod init)

  2. Include this library in the project (go get github.com/leep-frog/command)

  3. 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...))
}
  1. cd into your project, run the following onetime setup, and follow the instructions provided in the output:
go run . source myCLIs $OUTPUT_FOLDER

Writing Your First Command

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.

Building Blocks Docs

Example

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:

  1. Download the example_main.go file locally and read through the file to become familiar with CLI setup (the file is thoroughly commented).

  2. cd into the local directory containing the example_main.go file.

  3. 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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages