cli

package
v0.0.0-...-9a6de97 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package cli provides common helpers for the ksync cmds.

These helpers provide:

  • A common way to access and handle configuration via. viper.
  • Flags that get used by all ksync cmds.
  • Logging configuration and setup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindFlag

func BindFlag(v *viper.Viper, flag *pflag.Flag, root string) error

BindFlag moves cobra flags into viper for exclusive use there.

func ConfigPath

func ConfigPath() string

ConfigPath returns the directory path being used by config.

func DefaultFlags

func DefaultFlags(cmd *cobra.Command, name string) error

DefaultFlags configures a standard set of flags for every command and sub-command.

func InitConfig

func InitConfig(name string) error

InitConfig constructs the configuration from a local configuration file or environment variables if available. This is placed in the global `viper` instance.

func InitLogging

func InitLogging()

InitLogging initializes the logging engine with the configured values.

func TaskOut

func TaskOut(name string, fn func() error) error

TaskOut provides a way to pretty print a long running function with colors and spinners.

Types

type BaseCmd

type BaseCmd struct {
	Root  string
	Cmd   *cobra.Command
	Viper *viper.Viper
}

BaseCmd provides helpers for generic sub-commands.

func (*BaseCmd) BindFlag

func (b *BaseCmd) BindFlag(name string) error

BindFlag plumbs a flag into viper so that it can be used exclusively.

func (*BaseCmd) Init

func (b *BaseCmd) Init(root string, cmd *cobra.Command)

Init sets up the cmd to have flags added.

type FinderCmd

type FinderCmd struct {
	BaseCmd
}

FinderCmd parses the options required to discover a remote container.

func (*FinderCmd) DefaultFlags

func (cmd *FinderCmd) DefaultFlags() error

DefaultFlags configures the default flags to find a container.

func (*FinderCmd) Validator

func (cmd *FinderCmd) Validator() error

Validator ensures that the command has valid arguments.

Jump to

Keyboard shortcuts

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