Documentation ¶
Overview ¶
Package cli contains utility for the cli
Index ¶
- Variables
- func ConcatenateAndWrap(input string, maxLen int) string
- func ExitNicelyOnError(err error, userMsg string)
- func GRPCClientWrapRunE(...) func(cmd *cobra.Command, args []string) error
- func GetAppContext(ctx context.Context, v *viper.Viper) (context.Context, context.CancelFunc)
- func GetAppContextWithTimeoutDuration(ctx context.Context, v *viper.Viper, tout int) (context.Context, context.CancelFunc)
- func GetNameAndOwnerFromRepository(repository string) (string, string)
- func GetRepositoryName(owner, name string) string
- func GrpcForCommand(v *viper.Viper) (*grpc.ClientConn, error)
- func MessageAndError(msg string, err error) error
- func MultiSelect(choices []string) ([]string, error)
- func PrintYesNoPrompt(cmd *cobra.Command, promptMsg, confirmMsg, fallbackMsg string, defaultYes bool) bool
- func ValidateRepositoryName(repository string) error
- type ErrWrappedCLIError
Constants ¶
This section is empty.
Variables ¶
var ( // PrimaryColor is the primary color for the cli. PrimaryColor = lipgloss.Color("#00BBBE") // SecondaryColor is the secondary color for the cli. SecondaryColor = lipgloss.Color("#59CFA8") // AccentColor is the accent color for the cli. AccentColor = lipgloss.Color("#3D34E0") // WhiteColor is the white color for the cli. WhiteColor = lipgloss.Color("#FFFFFF") // BlackColor is the black color for the cli. BlackColor = lipgloss.Color("#000000") )
Color Palette
var ( // DefaultBannerWidth is the default width for a banner DefaultBannerWidth = 80 // Header is the style to use for headers Header = lipgloss.NewStyle(). Bold(true). Foreground(PrimaryColor). PaddingTop(1). PaddingBottom(1). PaddingLeft(1). PaddingRight(1). MaxWidth(80) WarningBanner = lipgloss.NewStyle(). Bold(true). Background(BlackColor). Foreground(WhiteColor). BorderForeground(AccentColor). PaddingTop(2). PaddingBottom(2). PaddingLeft(4). PaddingRight(4). Width(DefaultBannerWidth) // SuccessBanner is the style to use for a success banner SuccessBanner = lipgloss.NewStyle(). Bold(true). Background(AccentColor). Foreground(WhiteColor). PaddingTop(1). PaddingBottom(1). PaddingLeft(4). PaddingRight(4). Width(DefaultBannerWidth) )
Styles
Functions ¶
func ConcatenateAndWrap ¶ added in v0.0.30
ConcatenateAndWrap takes a string and a maximum line length (maxLen), then outputs the string as a multiline string where each line does not exceed maxLen characters.
func ExitNicelyOnError ¶ added in v0.0.22
ExitNicelyOnError print a message and exit with the right code
func GRPCClientWrapRunE ¶ added in v0.0.20
func GRPCClientWrapRunE( runEFunc func(ctx context.Context, cmd *cobra.Command, args []string, c *grpc.ClientConn) error, ) func(cmd *cobra.Command, args []string) error
GRPCClientWrapRunE is a wrapper for cobra commands that sets up the grpc client and context
func GetAppContext ¶ added in v0.0.20
GetAppContext is a helper for getting the cmd app context
func GetAppContextWithTimeoutDuration ¶ added in v0.0.21
func GetAppContextWithTimeoutDuration(ctx context.Context, v *viper.Viper, tout int) (context.Context, context.CancelFunc)
GetAppContextWithTimeoutDuration is a helper for getting the cmd app context with a custom timeout
func GetNameAndOwnerFromRepository ¶ added in v0.0.45
GetNameAndOwnerFromRepository returns the owner and name from a repository name in the format owner/name
func GetRepositoryName ¶ added in v0.0.24
GetRepositoryName returns the repository name in the format owner/name
func GrpcForCommand ¶ added in v0.0.20
func GrpcForCommand(v *viper.Viper) (*grpc.ClientConn, error)
GrpcForCommand is a helper for getting a testing connection from cobra flags
func MessageAndError ¶ added in v0.0.21
MessageAndError prints a message and returns an error.
func MultiSelect ¶ added in v0.0.49
MultiSelect implements the necessary logic to implement an interactive multi-select menu for the CLI.
Given a list of string as choices, returns those interactively selected by the user.
func PrintYesNoPrompt ¶
func PrintYesNoPrompt(cmd *cobra.Command, promptMsg, confirmMsg, fallbackMsg string, defaultYes bool) bool
PrintYesNoPrompt prints a yes/no prompt to the user and returns false if the user did not respond with yes or y
func ValidateRepositoryName ¶ added in v0.0.45
ValidateRepositoryName checks if a repository name is valid
Types ¶
type ErrWrappedCLIError ¶ added in v0.0.22
ErrWrappedCLIError is an error that wraps another error and provides a message used from within the CLI
func (*ErrWrappedCLIError) Error ¶ added in v0.0.22
func (e *ErrWrappedCLIError) Error() string
Directories ¶
Path | Synopsis |
---|---|
Package table contains utilities for rendering tables
|
Package table contains utilities for rendering tables |
layouts
Package layouts defines the available table layouts
|
Package layouts defines the available table layouts |
simple
Package simple contains a simple table
|
Package simple contains a simple table |
Package useragent contains utilities for setting up the CLI's user agent
|
Package useragent contains utilities for setting up the CLI's user agent |