cmdBuilder

package
v1.0.55 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2025 License: MIT Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const ProjectArgName = "project-id"
View Source
const ServiceArgName = "service-id-or-name"

Variables

This section is empty.

Functions

func ExecuteRootCmd added in v1.0.5

func ExecuteRootCmd(rootCmd *Cmd)

func ProjectScopeReset added in v1.0.46

func ProjectScopeReset(cmdData *LoggedUserCmdData) error

Types

type ArgOption

type ArgOption = func(cfg *cmdArg)

func ArrayArg

func ArrayArg() ArgOption

func OptionalArg

func OptionalArg() ArgOption

func OptionalArgLabel

func OptionalArgLabel(label string) ArgOption

type Cmd

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

func NewCmd

func NewCmd() *Cmd

func (*Cmd) AddChildrenCmd

func (c *Cmd) AddChildrenCmd(childrenCmd *Cmd) *Cmd

func (*Cmd) Arg

func (c *Cmd) Arg(name string, auxOptions ...ArgOption) *Cmd

func (*Cmd) BoolFlag

func (c *Cmd) BoolFlag(name string, defaultValue bool, description string, auxOptions ...FlagOption) *Cmd

func (*Cmd) GuestRunFunc

func (c *Cmd) GuestRunFunc(runFunc guestRunFunc) *Cmd

func (*Cmd) HelpFlag

func (c *Cmd) HelpFlag(description string, auxOptions ...FlagOption) *Cmd

func (*Cmd) IntFlag

func (c *Cmd) IntFlag(name string, defaultValue int, description string, auxOptions ...FlagOption) *Cmd

func (*Cmd) LoggedUserRunFunc

func (c *Cmd) LoggedUserRunFunc(runFunc loggedUserRunFunc) *Cmd

func (*Cmd) Long

func (c *Cmd) Long(long string) *Cmd

func (*Cmd) ScopeLevel

func (c *Cmd) ScopeLevel(scopeLevel ScopeLevel) *Cmd

func (*Cmd) SetHelpTemplate added in v1.0.5

func (c *Cmd) SetHelpTemplate(template string) *Cmd

func (*Cmd) Short

func (c *Cmd) Short(short string) *Cmd

func (*Cmd) SilenceError added in v1.0.8

func (c *Cmd) SilenceError(silenceError bool) *Cmd

func (*Cmd) SilenceUsage

func (c *Cmd) SilenceUsage(silenceUsage bool) *Cmd

func (*Cmd) StringFlag

func (c *Cmd) StringFlag(name string, defaultValue string, description string, auxOptions ...FlagOption) *Cmd

func (*Cmd) StringSliceFlag added in v1.0.46

func (c *Cmd) StringSliceFlag(name string, defaultValue []string, description string, auxOptions ...FlagOption) *Cmd

func (*Cmd) Use

func (c *Cmd) Use(use string) *Cmd

type FlagOption

type FlagOption = func(cfg *cmdFlag)

func HiddenFlag

func HiddenFlag() FlagOption

func ShortHand

func ShortHand(shorthand string) FlagOption

type GuestCmdData

type GuestCmdData struct {
	CliStorage *cliStorage.Handler
	UxBlocks   *uxBlock.Blocks
	Args       map[string][]string
	Params     flagParams.ParamsReader
	Stdout     printer.Printer
	Stderr     printer.Printer

	PrintHelp func()
}

type LoggedUserCmdData

type LoggedUserCmdData struct {
	*GuestCmdData
	RestApiClient *zeropsRestApiClient.Handler

	// optional params
	Project optional.Null[entity.Project]
	Service optional.Null[entity.Service]

	ProjectSelector func(context.Context, *LoggedUserCmdData, ...uxHelpers.ProjectSelectorOption) (entity.Project, bool, error)

	VpnKeys map[uuid.ProjectId]entity.VpnKey
}

type ProjectOption added in v1.0.46

type ProjectOption gn.Option[projectScope]

func WithCreateNewProject added in v1.0.46

func WithCreateNewProject() ProjectOption

WithCreateNewProject allows 'create new project' option in selector

func WithSkipSelectProject added in v1.0.49

func WithSkipSelectProject() ProjectOption

WithSkipSelectProject allows skip project select

type ScopeLevel

type ScopeLevel interface {
	AddCommandFlags(*Cmd)
	LoadSelectedScope(ctx context.Context, cmd *Cmd, cmdData *LoggedUserCmdData) error
}

func ScopeProject added in v1.0.46

func ScopeProject(opts ...ProjectOption) ScopeLevel

func ScopeService added in v1.0.46

func ScopeService(opts ...ServiceOption) ScopeLevel

type ServiceOption added in v1.0.46

type ServiceOption gn.Option[serviceScope]

func WithCreateNewService added in v1.0.46

func WithCreateNewService() ServiceOption

WithCreateNewService allows 'create new service' option in selector

func WithProjectScopeOptions added in v1.0.46

func WithProjectScopeOptions(opts ...ProjectOption) ServiceOption

Jump to

Keyboard shortcuts

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