Home

Awesome

Contributors GitHub release GitHub All Releases

Go CLI Alias

Adding a command alias feature for your CLI.

Get started

go get github.com/linuxsuren/go-cli-alias

Put the following code lines:

var ctx context.Context
if defMgr, err := alias.GetDefaultAliasMgr(); err == nil {
    ctx = context.WithValue(context.Background(), alias.AliasKey, defMgr)

    rootCmd.AddCommand(cmd.NewRootCommand(ctx))

    cmd.RegisterAliasCommands(ctx, rootCmd)
} else {
    fmt.Println(fmt.Errorf("cannot get default alias manager, error: %v", err))
}