Skip to content

haijima/cobrax

Repository files navigation

cobrax

CI Status Go Reference Go report

A utility library for spf13/cobra, spf13/viper and spf13/afero.

Usage

var version, commit, date string // main.version, main.commit, main.date

cmd := cobrax.NewRoot(viper.New())
cmd.Use = "app"
cmd.Short = "description of app"
cmd.Version = cobrax.VersionFunc(version, commit, date)

cmd.AddCommand(someCmd)
cmd.AddCommand(otherCmd)

cmd.Execute()
// Open the file. When pipe is used and the filename is empty, read from stdin.
cobrax.OpenOrStdIn(viper.GetString("filename"), afero.NewOsFs()) 
// Read the config file and set the values to the viper.
cobrax.BindConfigs(v, "app")

License

This tool is licensed under the MIT License. See the LICENSE file for details.

Links