cmd

package
v0.0.0-...-c8d3d99 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const VariablePlaceHolderPrefix = "$"

Variables

View Source
var ConfigurationsRelativeFileExtension = ".yaml"
View Source
var ConfigurationsRelativeFilePath = "./configurations"
View Source
var Resources = map[string]Resource{}

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()

Types

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
	Pagination       *Pagination `yaml:"pagination,omitempty"` // Pagination configuration
}

func (*Command) Run

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

func (*Command) RunWithPaginationToken

func (command *Command) RunWithPaginationToken(resource string, profile string, paginationToken string) string
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 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
}
var UiState UIState = UIState{SelectedItems: make(map[string]string), Breadcrumbs: []string{}, NavigationStack: []NavigationState{}, CommandCache: make(map[string]string)}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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