cli

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: BSD-3-Clause-Clear Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// top level actions
	ActionGet          = "get"
	ActionList         = "list"
	ActionCreate       = "create"
	ActionUpdate       = "update"
	ActionUpdateUnsafe = "unsafely update"
	ActionDeactivate   = "deactivate"
	ActionReactivate   = "reactivate"
	ActionDelete       = "delete"

	// text input names
	InputNameFQN        = "fully qualified name (FQN)"
	InputNameFQNUpdated = "deprecated fully qualified name (FQN) being altered"
)
View Source
const (
	FlexColumnWidthOne   = 1
	FlexColumnWidthTwo   = 2
	FlexColumnWidthThree = 3
	FlexColumnWidthFour  = 4
	FlexColumnWidthFive  = 5
)

Variables

View Source
var ErrPrinterExpectsCommand = fmt.Errorf("printer expects a command")

Functions

func AskForInput added in v0.10.0

func AskForInput(message string) string

func AskForSecret added in v0.10.0

func AskForSecret(message string) string

func CommaSeparated

func CommaSeparated(values []string) string

func ConfirmAction

func ConfirmAction(action, resource, id string, force bool)

func ConfirmTextInput

func ConfirmTextInput(action, resource, inputName, shouldMatchValue string)

func ConstructMetadata

func ConstructMetadata(m *common.Metadata) map[string]string

func DebugMessage added in v0.13.0

func DebugMessage(msg string) string

func ErrorMessage

func ErrorMessage(msg string, err error) string

func ExitWithError

func ExitWithError(errMsg string, err error)

func ExitWithNotFoundError

func ExitWithNotFoundError(errMsg string, err error)

func ExitWithWarning

func ExitWithWarning(warnMsg string)

func FooterMessage

func FooterMessage(msg string) string

func GetState

func GetState(cmd *cobra.Command) common.ActiveStateEnum

Transforms into enum value and defaults to active state

func NewTable

func NewTable(cols ...table.Column) table.Model

func NewTabular

func NewTabular(rows ...[]string) table.Model

func NewUUIDColumn

func NewUUIDColumn() table.Column

func PrettyList added in v0.16.0

func PrettyList(values []string) string

func PrintSuccessTable

func PrintSuccessTable(cmd *cobra.Command, id string, t table.Model)

func ReadFromArgsOrPipe

func ReadFromArgsOrPipe(args []string, pipe *os.File) []byte

func ReadFromFile

func ReadFromFile(filePath string) []byte

func ReadFromPipe

func ReadFromPipe(in *os.File) []byte

func SuccessMessage

func SuccessMessage(msg string) string

func TermWidth

func TermWidth() int

Returns the terminal width (overridden by the TEST_TERMINAL_WIDTH env var for testing)

func WarningMessage

func WarningMessage(msg string) string

func WithListPaginationFooter added in v0.17.0

func WithListPaginationFooter(t table.Model, p *policy.PageResponse) table.Model

Adds the page information to the table footer

func WithPrintJson added in v0.13.0

func WithPrintJson() cliVariadicOption

WithPrintJson is a variadic option that enforces JSON output for the printer

Types

type Cli added in v0.13.0

type Cli struct {

	// Helpers
	Flags      *flagHelper
	FlagHelper *flagHelper
	// contains filtered or unexported fields
}

func New added in v0.13.0

func New(cmd *cobra.Command, args []string, options ...cliVariadicOption) *Cli

New creates a new Cli object

func (*Cli) Cmd added in v0.13.0

func (c *Cli) Cmd() *cobra.Command

func (*Cli) Context added in v0.13.0

func (c *Cli) Context() context.Context

func (*Cli) Debug added in v0.13.0

func (c *Cli) Debug(args ...interface{})

func (*Cli) Debugf added in v0.13.0

func (c *Cli) Debugf(format string, args ...interface{})

func (*Cli) Debugln added in v0.13.0

func (c *Cli) Debugln(args ...interface{})

func (*Cli) ExitWithError added in v0.13.0

func (c *Cli) ExitWithError(errMsg string, err error)

ExitWithError prints an error message and exits with a non-zero status code.

func (*Cli) ExitWithJSON added in v0.13.0

func (c *Cli) ExitWithJSON(v interface{})

func (*Cli) ExitWithMessage added in v0.13.0

func (c *Cli) ExitWithMessage(msg string, code int)

func (*Cli) ExitWithNotFoundError added in v0.13.0

func (c *Cli) ExitWithNotFoundError(errMsg string, err error)

ExitWithNotFoundError prints an error message and exits with a non-zero status code if the error is a NotFound error.

func (*Cli) ExitWithSuccess added in v0.13.0

func (c *Cli) ExitWithSuccess(msg string)

func (*Cli) ExitWithWarning added in v0.13.0

func (c *Cli) ExitWithWarning(warnMsg string)

func (*Cli) Print added in v0.13.0

func (c *Cli) Print(args ...interface{})

func (*Cli) PrintIfJSON added in v0.13.0

func (c *Cli) PrintIfJSON(v interface{})

func (*Cli) PrintJson added in v0.13.0

func (c *Cli) PrintJson(v interface{})

PrintJson prints the given value as json ignores the printer enabled flag

func (*Cli) Printf added in v0.13.0

func (c *Cli) Printf(format string, args ...interface{})

func (*Cli) Println added in v0.13.0

func (c *Cli) Println(args ...interface{})

type Color

type Color struct {
	Foreground lipgloss.CompleteAdaptiveColor
	Background lipgloss.CompleteAdaptiveColor
}

type FlagsStringSliceOptions added in v0.13.0

type FlagsStringSliceOptions struct {
	Min int
	Max int
}

type Printer added in v0.10.0

type Printer struct {
	// contains filtered or unexported fields
}

type SimpleAttribute

type SimpleAttribute struct {
	Id        string
	Name      string
	Rule      string
	Values    []string
	Namespace string
	Active    string
	Metadata  map[string]string
}

func GetSimpleAttribute

func GetSimpleAttribute(a *policy.Attribute) SimpleAttribute

type SimpleAttributeValue

type SimpleAttributeValue struct {
	Id       string
	FQN      string
	Active   string
	Metadata map[string]string
}

func GetSimpleAttributeValue

func GetSimpleAttributeValue(v *policy.Value) SimpleAttributeValue

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳