Documentation
¶
Overview ¶
Package cmdutil provides command utilities for iTerm2 CLI operations
Package cmdutil provides command utilities for iTerm2 CLI operations
Index ¶
- func BoolPtr(b bool) *bool
- func Doc(text string) string
- func Docf(text string, args ...interface{}) string
- func Int32Ptr(i int32) *int32
- func IsSessionCommand(cmd *cobra.Command) bool
- func NewCommandFromTemplate(template CommandTemplate) *cobra.Command
- func PrintScopeNoticeWithFlag(format string, scopeFlag string)
- func StringPtr(s string) *string
- type CommandTemplate
- type SharedListOperations
- func (s *SharedListOperations) ListSessions(opts SharedListOptions) error
- func (s *SharedListOperations) ListTabs(opts SharedListOptions) error
- func (s *SharedListOperations) ListWindows(opts SharedListOptions) error
- func (s *SharedListOperations) ResolveWindowID(windowIDOrIndex string) (string, error)
- type SharedListOptions
- type StandardCommand
- func (sc *StandardCommand) AddExtendedFlags()
- func (sc *StandardCommand) AddStandardFlags()
- func (sc *StandardCommand) ExecuteWithClient(fn func(*client.Client, context.Context) error) error
- func (sc *StandardCommand) FormatOutput(data interface{}) error
- func (sc *StandardCommand) GetClient() *client.Client
- func (sc *StandardCommand) GetCommand() *cobra.Command
- func (sc *StandardCommand) GetContext() context.Context
- func (sc *StandardCommand) GetCurrentWindowID() (string, error)
- func (sc *StandardCommand) GetFlags() *StandardFlags
- func (sc *StandardCommand) ParseFlags() error
- func (sc *StandardCommand) ReportError(operation string, err error) error
- func (sc *StandardCommand) ReportSuccess(format string, args ...interface{})
- type StandardFlags
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Doc ¶
Doc processes a heredoc string by removing common leading whitespace and normalizing line endings. This is similar to the MakeNowJust/heredoc library but simplified for our use case.
func Docf ¶
Docf processes a heredoc string like Doc but also performs fmt.Sprintf formatting with the provided arguments.
func IsSessionCommand ¶
IsSessionCommand checks if the current command expects a session context
func NewCommandFromTemplate ¶
func NewCommandFromTemplate(template CommandTemplate) *cobra.Command
NewCommandFromTemplate creates a standardized cobra command from a template
func PrintScopeNoticeWithFlag ¶
PrintScopeNoticeWithFlag prints scope notice respecting both env var and flag override
Types ¶
type CommandTemplate ¶
type CommandTemplate struct {
Use string
Short string
Long string
Example string
Args cobra.PositionalArgs
RequiresClient bool
RequiresSession bool
SupportsSorting bool
SupportsColumns bool
SupportsFormat bool
NoTimeout bool // Override default timeout for long-running commands
ValidArgsFunc func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)
PreRunE func(cmd *cobra.Command, args []string) error
RunE func(*StandardCommand, []string) error
}
CommandTemplate provides a standard command structure
type SharedListOperations ¶
type SharedListOperations struct {
// contains filtered or unexported fields
}
SharedListOperations provides shared listing functionality for both flat and hierarchical commands
func NewSharedListOperations ¶
func NewSharedListOperations(client *client.Client, ctx context.Context) *SharedListOperations
NewSharedListOperations creates a new instance with client and context
func (*SharedListOperations) ListSessions ¶
func (s *SharedListOperations) ListSessions(opts SharedListOptions) error
ListSessions lists sessions with optional filtering by window and tab
func (*SharedListOperations) ListTabs ¶
func (s *SharedListOperations) ListTabs(opts SharedListOptions) error
ListTabs lists tabs with optional filtering by window
func (*SharedListOperations) ListWindows ¶
func (s *SharedListOperations) ListWindows(opts SharedListOptions) error
ListWindows lists all windows
func (*SharedListOperations) ResolveWindowID ¶
func (s *SharedListOperations) ResolveWindowID(windowIDOrIndex string) (string, error)
ResolveWindowID converts a window index (like "0", "1") to the actual window UUID Returns the input unchanged if it's already a UUID or if resolution fails
type SharedListOptions ¶
type SharedListOptions struct {
}
SharedListOptions contains common options for list operations
type StandardCommand ¶
type StandardCommand struct {
// contains filtered or unexported fields
}
StandardCommand provides the foundation for all commands with common setup
func NewStandardCommand ¶
func NewStandardCommand(use, short string) *StandardCommand
NewStandardCommand creates a command with standard setup
func (*StandardCommand) AddExtendedFlags ¶
func (sc *StandardCommand) AddExtendedFlags()
AddExtendedFlags adds sorting/filtering flags
func (*StandardCommand) AddStandardFlags ¶
func (sc *StandardCommand) AddStandardFlags()
AddStandardFlags adds common flags to commands
func (*StandardCommand) ExecuteWithClient ¶
ExecuteWithClient runs a command with standard connection handling
func (*StandardCommand) FormatOutput ¶
func (sc *StandardCommand) FormatOutput(data interface{}) error
FormatOutput formats and outputs data based on standard flags
func (*StandardCommand) GetClient ¶
func (sc *StandardCommand) GetClient() *client.Client
GetClient returns the connected client (if any)
func (*StandardCommand) GetCommand ¶
func (sc *StandardCommand) GetCommand() *cobra.Command
GetCommand returns the underlying cobra command
func (*StandardCommand) GetContext ¶
func (sc *StandardCommand) GetContext() context.Context
GetContext returns the command context
func (*StandardCommand) GetCurrentWindowID ¶
func (sc *StandardCommand) GetCurrentWindowID() (string, error)
GetCurrentWindowID returns the window ID of the current session
func (*StandardCommand) GetFlags ¶
func (sc *StandardCommand) GetFlags() *StandardFlags
GetFlags returns the standard flags
func (*StandardCommand) ParseFlags ¶
func (sc *StandardCommand) ParseFlags() error
ParseFlags extracts flag values from the command
func (*StandardCommand) ReportError ¶
func (sc *StandardCommand) ReportError(operation string, err error) error
ReportError reports an error with standard formatting. Context deadline errors include the configured timeout and a hint about --timeout.
func (*StandardCommand) ReportSuccess ¶
func (sc *StandardCommand) ReportSuccess(format string, args ...interface{})
ReportSuccess reports a successful operation