cmd

package
v0.8.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package cmd provides a common utilities and helper function to standarise the way omni apps use cobra and viper to produce consistent cli experience for both users and devs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindHomeFlag

func BindHomeFlag(flags *pflag.FlagSet, homeDir *string)

BindHomeFlag binds the home flag to the given flag set. This is generally only required for apps that require multiple config files or persist data to disk. Using this flag will result in the viper config directory to be updated from default "." to "<home>/config".

func LogFlags

func LogFlags(ctx context.Context, flags *pflag.FlagSet) error

LogFlags logs the configured flags kv pairs.

func Main

func Main(cmd *cobra.Command)

Main is the main entry point for the command line tool. Usage:

   func main() {
	     libcmd.Main(appcmd.New())
   }

func NewRootCmd

func NewRootCmd(appName string, appDescription string, subCmds ...*cobra.Command) *cobra.Command

NewRootCmd returns a new root cobra command that handles our command line tool. It sets up the general viper config and binds the cobra flags to the viper flags. It also silences the usage printing when commands error during "running".

func SilenceErrUsage

func SilenceErrUsage(cmd *cobra.Command)

SilenceErrUsage silences the usage and error printing.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL