Skip to content

LinuxSuRen/go-cli-alias

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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))
}