cmd

package
v0.0.0-...-cee8b2a Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigurationsDir = "configurations"
View Source
const ConfigurationsFileExtension = ".yaml"
View Source
const VariablePlaceHolderPrefix = "$"

Variables

View Source
var Favourites = &FavouritesStore{}

Favourites is the global singleton for managing favourited items.

View Source
var Resources = map[string]Resource{}
View Source
var Settings = &SettingsStore{}

Settings is the global singleton for user settings.

Functions

func ExtractPaginationToken

func ExtractPaginationToken(jsonOutput string, command Command) string

ExtractPaginationToken extracts the next page token from JSON output

func GetAvailableResourceNames

func GetAvailableResourceNames() []string

func Init

func Init(embeddedFS fs.FS)

Init loads all YAML configuration files from the embedded filesystem.

func StripFavouritePrefix

func StripFavouritePrefix(name string) string

StripFavouritePrefix removes the favourite star prefix from an item name.

Types

type Action

type Action struct {
	Type          string `yaml:"type"`          // Action type, e.g. "download"
	Rune          string `yaml:"rune"`          // Single character shortcut key
	Description   string `yaml:"description"`   // Description shown in shortcut bar
	TargetCommand string `yaml:"targetCommand"` // Which command to execute for this action
}
type BreadcrumbType string
const (
	BreadcrumbProfiles      BreadcrumbType = "profiles"
	BreadcrumbProfile       BreadcrumbType = "profile"
	BreadcrumbResource      BreadcrumbType = "resource"
	BreadcrumbCommand       BreadcrumbType = "command"
	BreadcrumbSelectedItem  BreadcrumbType = "selected_item"
	BreadcrumbDependentCmds BreadcrumbType = "dependent_commands" // List of dependent commands to choose from
	BreadcrumbDependentCmd  BreadcrumbType = "dependent_command"
	BreadcrumbJsonView      BreadcrumbType = "json_view"
	BreadcrumbProcessedJson BreadcrumbType = "processed_json"
)

type Command

type Command struct {
	Name             string      `yaml:"name"`
	ResourceName     string      `yaml:"resourceName"`
	DefaultCommand   string      `yaml:"defaultCommand"`
	DependsOn        string      `yaml:"depends_on"`
	Arguments        []string    `yaml:"arguments"`
	View             string      `yaml:"view"`
	Parse            Parse       `yaml:"parse"`
	ShowJsonViewer   bool        `yaml:"showJsonViewer"`
	RerunOnBack      bool        `yaml:"rerunOnBack"`          // If true, rerun command when navigating back; if false, use cached result
	RequiresKeyInput bool        `yaml:"requiresKeyInput"`     // If true, prompt user for key value before executing
	Favouritable     bool        `yaml:"favouritable"`         // If true, enable 'f' shortcut to toggle favourites
	Pagination       *Pagination `yaml:"pagination,omitempty"` // Pagination configuration
	Actions          []Action    `yaml:"actions,omitempty"`    // Context-specific actions (e.g., download)
}

func (*Command) Run

func (command *Command) Run(resource string, profile string) string

func (*Command) RunToFile

func (command *Command) RunToFile(resource string, profile string, outFile string) string

RunToFile runs the command with an output file as the last positional argument. Used for commands like s3api get-object that download content to a file. Returns the file path and the CLI metadata output.

func (*Command) RunWithPaginationToken

func (command *Command) RunWithPaginationToken(resource string, profile string, paginationToken string) string

type FavouritesStore

type FavouritesStore struct {
	Items map[string][]string `yaml:"favourites"`
	// contains filtered or unexported fields
}

FavouritesStore holds the favourites data keyed by "resource:command" -> list of item names.

func (*FavouritesStore) ApplyFavourites

func (f *FavouritesStore) ApplyFavourites(resource string, command string, rows [][]string, rowData []interface{}) ([][]string, []interface{})

ApplyFavourites reorders rows so favourited items appear at the top with a star prefix on their first column. rowData (for JSON viewer) is reordered in sync. Returns the reordered rows and rowData.

func (*FavouritesStore) IsFavourite

func (f *FavouritesStore) IsFavourite(resource string, command string, item string) bool

IsFavourite checks if an item is a favourite for the given resource:command.

func (*FavouritesStore) Load

func (f *FavouritesStore) Load()

Load reads the favourites file from disk. If it doesn't exist, starts empty.

func (*FavouritesStore) Save

func (f *FavouritesStore) Save()

Save writes the favourites to disk.

func (*FavouritesStore) Toggle

func (f *FavouritesStore) Toggle(resource string, command string, item string) bool

Toggle adds or removes an item from the favourites for the current resource:command. Returns true if the item is now a favourite, false if it was removed.

type NavigationState struct {
	Type              BreadcrumbType
	Value             string
	CachedResult      string          // Cached command result for this navigation level
	CachedBody        tview.Primitive // Cached UI body for this navigation level
	ProcessedData     interface{}     // Processed JSON data at this level (for nested JSON)
	PaginationToken   string          // Next page token for paginated commands
	PaginationHistory []string        // Stack of previous page tokens for backward navigation
}

type Pagination

type Pagination struct {
	Enabled           bool   `yaml:"enabled"`
	NextTokenParam    string `yaml:"nextTokenParam"`    // Parameter name for next token (e.g., "--starting-token" or "--exclusive-start-key")
	NextTokenJsonPath string `yaml:"nextTokenJsonPath"` // JSON path to extract next token (e.g., "NextToken" or "LastEvaluatedKey")
}

type Parse

type Parse struct {
	Type          string `yaml:"type"`
	AttributeName string `yaml:"attributeName"`
}

type Resource

type Resource struct {
	Name           string    `yaml:"name"`
	DefaultCommand string    `yaml:"defaultCommand"`
	Commands       []Command `yaml:"commands"`
}

func (*Resource) GetCommand

func (resource *Resource) GetCommand(name string) Command

func (*Resource) GetCommandNames

func (resource *Resource) GetCommandNames() []string

type SettingsStore

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

SettingsStore holds the user-configurable settings, persisted to disk.

func (*SettingsStore) Load

func (s *SettingsStore) Load()

Load reads the settings file from disk. If it doesn't exist, starts with defaults (animations: false).

func (*SettingsStore) Save

func (s *SettingsStore) Save()

Save writes the settings to disk.

type TableData

type TableData struct {
	Title   string
	Headers []string
	Rows    [][]string
	RowData []interface{} // For JSON viewer
}

type UIState

type UIState struct {
	Profile                string            `yaml:"profile"`
	Resource               Resource          `yaml:"resource"`
	Command                Command           `yaml:"command"`
	SelectedItems          map[string]string `yaml:"selectedItems"`
	CommandBarVisible      bool              `yaml:"commandBarVisible"`
	Breadcrumbs            []string          `yaml:"breadcrumbs"`
	NavigationStack        []NavigationState // Enhanced navigation tracking
	CommandCache           map[string]string // Cache of command results: "resource:command:params" -> output
	ViewStack              []tview.Primitive
	ProcessedJsonData      interface{} // Stores processed JSON data (parsed or decompressed)
	JsonViewerCallback     func()      // Callback to rebuild JSON viewer
	SelectedNodeText       string      // Stores the text of the selected node for focus restoration
	CurrentPageToken       string      // Current page token for active paginated command
	PageHistory            []string    // Stack of page tokens for backward navigation
	OriginalTableData      *TableData  // Original unfiltered table data for search/filter
	ShowDynamoDBJsonFormat bool        // Toggle for DynamoDB JSON format vs regular JSON (true = DynamoDB style)
	InDynamoDBJsonViewer   bool        // True when viewing a DynamoDB item in the JSON viewer
	InContentView          bool        // True when viewing S3 object content (contentView)
	ContentViewPretty      bool        // True when content view is in pretty/formatted mode (toggled by 'v')
	ContentViewObjectKey   string      // Object key of the currently viewed content (for toggle rebuild)
	ContentViewData        []byte      // Raw bytes of the currently viewed content (for toggle rebuild)
}
var UiState UIState = UIState{SelectedItems: make(map[string]string), Breadcrumbs: []string{}, NavigationStack: []NavigationState{}, CommandCache: make(map[string]string)}

func (*UIState) PaginationPageInfo

func (u *UIState) PaginationPageInfo() (page int, hasNext bool)

PaginationPageInfo returns the current page number and whether a next page is available. Page number is derived from the length of the page history stack. HasNext is true when the current navigation state holds a non-empty pagination token.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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