Documentation
¶
Index ¶
- Constants
- func Execute(ctx context.Context, command Command, args []string, stdout, stderr io.Writer) error
- func LocalPackPath() (string, error)
- func RepoPackPath(start string) (string, error)
- func RepoRoot(start string) (string, error)
- func SortCommands(commands []ResolvedCommand)
- type Command
- type Pack
- func (p *Pack) AddCommand(command Command, scope string, source string) error
- func (p *Pack) DeleteCommand(path []string) bool
- func (p *Pack) EnsureVersion()
- func (p Pack) FindCommand(path []string) (Command, bool)
- func (p Pack) Save(path string) error
- func (p *Pack) UpdateCommand(path []string, fn func(*Command) error) error
- func (p Pack) Validate() error
- type ResolvedCommand
- type Step
- type Workspace
- func (w *Workspace) ActiveCommands(reserved [][]string) []ResolvedCommand
- func (w *Workspace) AddCommand(command Command, scope string) error
- func (w *Workspace) DeleteCommand(path []string, scope string) bool
- func (w *Workspace) ResolvedCommands(reserved [][]string) []ResolvedCommand
- func (w *Workspace) Save() error
- func (w *Workspace) SaveLocal() error
- func (w *Workspace) SaveRepo() error
- func (w *Workspace) UpdateCommand(path []string, scope string, fn func(*Command) error) error
Constants ¶
const ( PackVersion = 1 ScopeLocal = "local" StatusActive = "active" StatusDisabled = "disabled" StatusConflicted = "conflicted" StepTypeExec = "exec" StepTypeShell = "shell" )
Variables ¶
This section is empty.
Functions ¶
func LocalPackPath ¶
LocalPackPath returns the user-local command pack path.
func RepoPackPath ¶
RepoPackPath returns the shared pack path for the current repository.
func SortCommands ¶
func SortCommands(commands []ResolvedCommand)
SortCommands sorts commands by path for stable presentation.
Types ¶
type Command ¶
type Command struct {
Path []string `json:"path"`
Description string `json:"description,omitempty"`
Scope string `json:"scope"`
Source string `json:"source,omitempty"`
Enabled bool `json:"enabled"`
Revision int `json:"revision"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Steps []Step `json:"steps"`
}
Command describes one automation command.
func PackSummary ¶
PackSummary returns a deterministic presentation order for commands.
func (Command) DisplayName ¶
DisplayName returns a user-friendly command path.
type Pack ¶
Pack stores a complete command collection.
func LoadPackFile ¶
LoadPackFile loads a command pack from disk.
func (*Pack) AddCommand ¶
AddCommand appends a command to the pack after normalizing it.
func (*Pack) DeleteCommand ¶
DeleteCommand removes a command from the pack by path.
func (*Pack) EnsureVersion ¶
func (p *Pack) EnsureVersion()
EnsureVersion sets the pack version if needed.
func (Pack) FindCommand ¶
FindCommand returns a command by path.
func (*Pack) UpdateCommand ¶
UpdateCommand updates an existing command by path.
type ResolvedCommand ¶
type ResolvedCommand struct {
Command Command `json:"command"`
Status string `json:"status"`
ConflictReason string `json:"conflict_reason,omitempty"`
}
ResolvedCommand annotates a command with its runtime state.
type Step ¶
type Step struct {
Type string `json:"type"`
Dir string `json:"dir,omitempty"`
Env map[string]string `json:"env,omitempty"`
Command []string `json:"command,omitempty"`
Script string `json:"script,omitempty"`
}
Step describes one command action.
type Workspace ¶
Workspace represents local and repo-shared command packs together.
func LoadWorkspace ¶
LoadWorkspace loads the current user's command packs.
func (*Workspace) ActiveCommands ¶
func (w *Workspace) ActiveCommands(reserved [][]string) []ResolvedCommand
ActiveCommands returns commands that can be registered with Cobra.
func (*Workspace) AddCommand ¶
AddCommand stores a command in the requested scope.
func (*Workspace) DeleteCommand ¶
DeleteCommand removes a command from the requested scope.
func (*Workspace) ResolvedCommands ¶
func (w *Workspace) ResolvedCommands(reserved [][]string) []ResolvedCommand
ResolvedCommands returns all commands with state annotations.