cmdutil

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package cmdutil provides command utilities for iTerm2 CLI operations

Package cmdutil provides command utilities for iTerm2 CLI operations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolPtr

func BoolPtr(b bool) *bool

BoolPtr returns a pointer to a bool value

func Doc

func Doc(text string) string

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

func Docf(text string, args ...interface{}) string

Docf processes a heredoc string like Doc but also performs fmt.Sprintf formatting with the provided arguments.

func Int32Ptr

func Int32Ptr(i int32) *int32

Int32Ptr returns a pointer to an int32 value

func IsSessionCommand

func IsSessionCommand(cmd *cobra.Command) bool

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

func PrintScopeNoticeWithFlag(format string, scopeFlag string)

PrintScopeNoticeWithFlag prints scope notice respecting both env var and flag override

func StringPtr

func StringPtr(s string) *string

StringPtr returns a pointer to a string value

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 {
	WindowID      string
	TabID         string
	SessionID     string
	Filter        string
	ScopeFlag     string
	Format        string
	Columns       []string
	SortBy        string
	SortReverse   bool
	Quiet         bool
	NoHyperlinks  bool
	PluginPattern *regexp.Regexp
	SkipPlugins   bool
	IncludeBuried bool
}

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

func (sc *StandardCommand) ExecuteWithClient(fn func(*client.Client, context.Context) error) error

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

type StandardFlags

type StandardFlags struct {
	WsURL       string
	Timeout     time.Duration
	Format      string
	Columns     []string
	SortBy      string
	SortReverse bool
	Quiet       bool
}

StandardFlags contains common flags used across commands

Jump to

Keyboard shortcuts

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