Documentation ¶
Overview ¶
Package cmdr provides abstractions to simplify and consolidate use of cobra and viper for cli applications.
Index ¶
- Variables
- func FlagValBool(name string) bool
- func FlagValBoolDefault(name string, def bool) bool
- func FlagValString(name string) string
- func FlagValStringDefault(name string, def string) string
- func NewManCommand(title string) *cobra.Command
- type App
- type BoolFlag
- type Command
- func (c *Command) AddCommand(commands ...*Command)
- func (c *Command) Children() []*Command
- func (c *Command) WithBoolFlag(f BoolFlag) *Command
- func (c *Command) WithPersistentBoolFlag(f BoolFlag) *Command
- func (c *Command) WithPersistentStringFlag(f BoolFlag) *Command
- func (c *Command) WithStringFlag(f StringFlag) *Command
- type StringFlag
Constants ¶
This section is empty.
Variables ¶
var ( Confirm pterm.InteractiveConfirmPrinter Prompt pterm.InteractiveTextInputPrinter )
var (
Info, Warning, Success, Fatal, Debug, Description, Error pterm.PrefixPrinter
Spinner pterm.SpinnerPrinter
ProgressBar pterm.ProgressbarPrinter
)
Functions ¶
func FlagValBool ¶
func FlagValBoolDefault ¶
func FlagValString ¶
func FlagValStringDefault ¶
func NewManCommand ¶
Types ¶
type App ¶
type App struct { Name string RootCommand *Command Logger *log.Logger *i18n.I18n // contains filtered or unexported fields }
The App struct represents the cli application with supporting functionality like internationalization and logging.
func NewApp ¶
NewApp creates a new command line application. It requires an embed.FS with a top level directory named 'locales'.
func (*App) CreateRootCommand ¶
type BoolFlag ¶
type BoolFlag struct { Value bool // contains filtered or unexported fields }
func NewBoolFlag ¶
type Command ¶
Command represents a cli command which may have flags, arguments, and children commands.
func NewCommand ¶
func NewCommand(use, long, short string, runE func(cmd *cobra.Command, args []string) error) *Command
NewCommand returns a new Command with the provided inputs
func NewCommandCustom ¶
NewCustomCommand returns a Command created from the provided cobra.Command
func (*Command) AddCommand ¶
AddCommand adds a command to the slice and to the underlying cobra command.
func (*Command) WithBoolFlag ¶
WithBoolFlag adds a boolean flag to the command and registers the flag with environment variable injection
func (*Command) WithPersistentBoolFlag ¶
WithPersistentBoolFlag adds a persistent boolean flag to the command and registers the flag with environment variable injection
func (*Command) WithPersistentStringFlag ¶
WithPersistentStringFlag adds a persistent string flag to the command and registers the command with the environment variable injection
func (*Command) WithStringFlag ¶
func (c *Command) WithStringFlag(f StringFlag) *Command
WithStringFlag adds a string flag to the command and registers the command with the environment variable injection
type StringFlag ¶
type StringFlag struct { Value string // contains filtered or unexported fields }
func NewStringFlag ¶
func NewStringFlag(name, shorthand, usage, value string) StringFlag