cli

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2025 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExecCommand = exec.Command

ExecCommand is a variable that can be mocked in tests

Functions

func AssertCommandError

func AssertCommandError(t *testing.T, cmd *cobra.Command, args []string, expectedErr string)

AssertCommandError checks that command fails with expected error

func AssertCommandOutput

func AssertCommandOutput(t *testing.T, cmd *cobra.Command, args []string, expected ...string)

AssertCommandOutput checks that command output contains expected strings

func CaptureOutput

func CaptureOutput(t *testing.T, fn func()) string

CaptureOutput captures stdout/stderr during function execution

func ConfirmDeployment

func ConfirmDeployment(preview *DeploymentPreview, forceYes bool) (bool, error)

ConfirmDeployment prompts for deployment confirmation with preview

func CreateTestComponent

func CreateTestComponent(t *testing.T, dir, name, language string)

CreateTestComponent creates a test component directory structure

func CreateTestProject

func CreateTestProject(t *testing.T, format string) string

CreateTestProject creates a temporary test project structure

func Debug

func Debug(format string, args ...interface{})

Debug prints a debug message if verbose mode is enabled

func Error

func Error(format string, args ...interface{})

Error prints an error message

func Execute

func Execute() error

Execute runs the root command

func ExecuteCommandTest

func ExecuteCommandTest(t *testing.T, test TestCommandExecution)

ExecuteCommandTest runs a command test with proper setup/teardown

func Fatal

func Fatal(format string, args ...interface{})

Fatal prints an error and exits

func Info

func Info(format string, args ...interface{})

Info prints an info message

func IsVerbose

func IsVerbose() bool

IsVerbose returns true if verbose mode is enabled

func MockExecCommandHelper

func MockExecCommandHelper(command string, args ...string) *exec.Cmd

MockExecCommandHelper is used to create fake commands for testing

func MockSurveyAsk

func MockSurveyAsk(responses map[string]interface{}) func(qs []*survey.Question, response interface{}, opts ...survey.AskOpt) error

MockSurveyAsk mocks survey.Ask for testing multiple prompts

func MockSurveyAskOne

func MockSurveyAskOne(response interface{}) func(p survey.Prompt, response interface{}, opts ...survey.AskOpt) error

MockSurveyAskOne mocks survey.AskOne for testing interactive prompts

func PrintStep

func PrintStep(step int, total int, message string)

PrintStep prints a step in a process

func SetVersion

func SetVersion(v, c, b string)

SetVersion sets the version information

func SetupTestEnvironment

func SetupTestEnvironment(t *testing.T, config TestConfig) string

SetupTestEnvironment creates a complete test environment

func ShowDeploymentPreview

func ShowDeploymentPreview(preview *DeploymentPreview)

ShowDeploymentPreview displays a comprehensive deployment preview

func Success

func Success(format string, args ...interface{})

Success prints a success message

func Warn

func Warn(format string, args ...interface{})

Warn prints a warning message

Types

type AddComponentOptions

type AddComponentOptions struct {
	Name        string
	Source      string
	Registry    string
	Description string
	Template    string
	Build       string
}

AddComponentOptions holds options for adding a component

type AddOptions

type AddOptions struct {
	Name     string
	Language string
}

AddOptions holds options for the add command

type ComponentPreview

type ComponentPreview struct {
	Name     string
	Type     string
	Source   string
	Size     string
	IsLocal  bool
	Registry string
	Version  string
}

ComponentPreview represents a component in the preview

type DataWriter

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

DataWriter handles formatted output of structured data

func NewDataWriter

func NewDataWriter(output io.Writer, format string) *DataWriter

NewDataWriter creates a new DataWriter

func (*DataWriter) WriteKeyValue

func (dw *DataWriter) WriteKeyValue(title string, data map[string]interface{}) error

WriteKeyValue writes key-value pairs in the specified format

func (*DataWriter) WriteStruct

func (dw *DataWriter) WriteStruct(data interface{}) error

WriteStruct writes a struct in the specified format

func (*DataWriter) WriteTable

func (dw *DataWriter) WriteTable(headers []string, rows [][]string) error

WriteTable writes tabular data with headers

type DeployOptions

type DeployOptions struct {
	Environment   string
	ConfigFile    string
	DryRun        bool
	Yes           bool
	AccessControl string
	JWTIssuer     string
	JWTAudience   string
	AllowedRoles  []string
	Variables     map[string]string
	OrgID         string // Explicitly specify organization ID
}

DeployOptions holds options for the deploy command

type DeploymentChanges

type DeploymentChanges struct {
	AccessModeChanged  bool
	OldAccessMode      string
	NewAccessMode      string
	ComponentsAdded    []string
	ComponentsRemoved  []string
	ComponentsUpdated  []string
	VariablesChanged   map[string]VariableChange
	EnvironmentChanged bool
	OldEnvironment     string
	NewEnvironment     string
}

DeploymentChanges tracks what's changing in an update

type DeploymentPreview

type DeploymentPreview struct {
	IsUpdate       bool
	AppName        string
	AppID          string
	AccessMode     string
	Environment    string
	Organization   string
	Components     []ComponentPreview
	Variables      map[string]string
	ExistingAppID  string
	ExistingAccess string
	Changes        *DeploymentChanges
}

DeploymentPreview represents the deployment preview information

func BuildDeploymentPreview

func BuildDeploymentPreview(
	manifest *validation.Application,
	opts *DeployOptions,
	existingAppID string,
	existingAccess string,
	orgID string,
) *DeploymentPreview

BuildDeploymentPreview creates a preview from the manifest and context

func BuildDeploymentPreviewWithOrg

func BuildDeploymentPreviewWithOrg(
	manifest *validation.Application,
	opts *DeployOptions,
	existingAppID string,
	existingAccess string,
	orgID string,
	orgName string,
) *DeploymentPreview

BuildDeploymentPreviewWithOrg creates a preview with full org information

type InitOptions

type InitOptions struct {
	Name          string
	Description   string
	Template      string
	Language      string // Configuration language: yaml, go, cue, json
	NoInteractive bool
	Force         bool
}

InitOptions holds options for the init command

type KeyValueBuilder

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

KeyValueBuilder helps build key-value data

func NewKeyValueBuilder

func NewKeyValueBuilder(title string) *KeyValueBuilder

NewKeyValueBuilder creates a new KeyValueBuilder

func (*KeyValueBuilder) Add

func (kvb *KeyValueBuilder) Add(key string, value interface{}) *KeyValueBuilder

Add adds a key-value pair

func (*KeyValueBuilder) AddIf

func (kvb *KeyValueBuilder) AddIf(condition bool, key string, value interface{}) *KeyValueBuilder

AddIf conditionally adds a key-value pair

func (*KeyValueBuilder) Write

func (kvb *KeyValueBuilder) Write(dw *DataWriter) error

Write outputs the key-value data using the DataWriter

type LogsOptions

type LogsOptions struct {
	// AppID can be either a UUID or an application name.
	// When a name is provided, it will be resolved to a UUID.
	AppID string

	// Since specifies the time range for logs.
	// Supported formats:
	// - Relative: "30m", "1h", "7d"
	// - RFC3339: "2024-01-15T10:00:00Z"
	// - Unix timestamp: "1705315200"
	Since string

	// Tail limits the number of log lines returned.
	// Valid range: 1-1000, default: 100
	Tail string
}

LogsOptions holds configuration for the logs command. All options are validated server-side to ensure consistency.

type MockCommandExecutor

type MockCommandExecutor struct {
	Commands map[string]*MockExecCommand
	History  []string
}

MockCommandExecutor manages mocked commands

func NewMockCommandExecutor

func NewMockCommandExecutor() *MockCommandExecutor

NewMockCommandExecutor creates a new mock executor

func (*MockCommandExecutor) Execute

func (m *MockCommandExecutor) Execute(name string, args ...string) ([]byte, error)

Execute simulates command execution

func (*MockCommandExecutor) GetHistory

func (m *MockCommandExecutor) GetHistory() []string

GetHistory returns command execution history

func (*MockCommandExecutor) RegisterCommand

func (m *MockCommandExecutor) RegisterCommand(cmd string, mock *MockExecCommand)

RegisterCommand registers a mock command

func (*MockCommandExecutor) ResetHistory

func (m *MockCommandExecutor) ResetHistory()

ResetHistory clears the command history

type MockExecCommand

type MockExecCommand struct {
	Command      string
	Args         []string
	ReturnOutput string
	ReturnError  error
	ReturnCode   int
}

MockExecCommand represents a mocked external command

type OutputFormat

type OutputFormat string

OutputFormat represents the output format type

const (
	OutputFormatTable OutputFormat = "table"
	OutputFormatJSON  OutputFormat = "json"
)

type TableBuilder

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

TableBuilder helps build table data incrementally

func NewTableBuilder

func NewTableBuilder(headers ...string) *TableBuilder

NewTableBuilder creates a new TableBuilder

func (*TableBuilder) AddRow

func (tb *TableBuilder) AddRow(values ...string) *TableBuilder

AddRow adds a row to the table

func (*TableBuilder) Write

func (tb *TableBuilder) Write(dw *DataWriter) error

Write outputs the table using the DataWriter

type TestCommandExecution

type TestCommandExecution struct {
	Command      *cobra.Command
	Args         []string
	ExpectError  bool
	ExpectOutput []string
	Setup        func(t *testing.T) string
	Cleanup      func(string)
	Validate     func(t *testing.T, output string, err error)
}

TestCommandExecution helps test cobra command execution

type TestComponent

type TestComponent struct {
	Name     string
	Language string
	Source   string
}

type TestConfig

type TestConfig struct {
	WorkDir      string
	ConfigFormat string
	Components   []TestComponent
}

TestConfig holds test configuration for commands

type VariableChange

type VariableChange struct {
	Old   string
	New   string
	Added bool
}

VariableChange represents a variable modification

Jump to

Keyboard shortcuts

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