Documentation
¶
Overview ¶
Package cli assembles module commands into a Cobra command tree. Applications own dependency construction, signal handling, and exit codes.
Index ¶
Constants ¶
const CommandTask = "app.command"
CommandTask is the persisted task type for allowlisted command invocations.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New validates and attaches fresh, unparented module commands to a root command. It does not open dependencies or start services. The caller owns the returned tree and should construct a fresh one per invocation; Cobra trees are mutable and must not execute concurrently. Errors are returned without being printed.
func NewQueueCommand ¶
NewQueueCommand builds native Asynq administration commands without I/O. Administrative commands are opt-in. They borrow the same bounded Redis client as workers and are intentionally absent from public HTTP routes. The inspector must be non-nil and remain open until command execution finishes.
Types ¶
type Config ¶
type Config struct {
Use string
Short string
Version string
In io.Reader
Out io.Writer
Err io.Writer
}
Config describes the root command and its streams. Nil streams use the process standard streams. Version is optional and enables Cobra's --version flag.
type ScheduledCommands ¶
type ScheduledCommands struct {
// contains filtered or unexported fields
}
ScheduledCommands is an explicit allowlist and native Asynq handler. Its zero value is ready to use. Install it with mux.Handle(CommandTask, commands). Register sequentially during assembly, then treat it as immutable. Each factory must return a fresh standalone command with no parent and no shared flag state. Commands borrow services, honor context cancellation and never exit the process.
func (*ScheduledCommands) ProcessTask ¶
ProcessTask runs one fresh command instance. The registry is read-only after registration, so different invocations can execute concurrently without sharing Cobra state. Unknown tasks and malformed payloads skip retries.