Documentation
¶
Overview ¶
Package interactive prompts for declared required inputs in an interactive terminal.
Package interactive centralizes the activation policy for prompt, form, and explorer surfaces.
Index ¶
- Constants
- func Declare(cmd *cobra.Command, spec CommandSpec) error
- func Intercept(root *cobra.Command)
- func IsInteractive(cmd *cobra.Command) bool
- func WithPrompter(ctx context.Context, p Prompter) context.Context
- type ArgSpec
- type CommandSpec
- type Decision
- type FormMode
- type PromptAnswer
- type PromptField
- type Prompter
Constants ¶
const PromptArgsAnnotation = "speakeasy_prompt_args"
Variables ¶
This section is empty.
Functions ¶
func IsInteractive ¶
Types ¶
type ArgSpec ¶ added in v0.1.68
type ArgSpec struct {
Name string `json:"name"`
Summary string `json:"summary,omitempty"`
Required bool `json:"required,omitempty"`
Variadic bool `json:"variadic,omitempty"`
BodyKey string `json:"body_key,omitempty"`
SatisfiedBy []string `json:"satisfied_by,omitempty"`
}
ArgSpec declares one promptable positional; SatisfiedBy names flags (no dashes) that replace it.
type CommandSpec ¶ added in v0.1.68
type CommandSpec struct {
Args []ArgSpec
}
type Decision ¶ added in v0.1.68
type Decision struct {
// contains filtered or unexported fields
}
func (Decision) AutoExplore ¶ added in v0.1.68
func (Decision) PromptRequiredInputs ¶ added in v0.1.68
func (Decision) ValidateDirectExplore ¶ added in v0.1.68
type PromptAnswer ¶ added in v0.1.68
type PromptField ¶ added in v0.1.68
type PromptField struct {
ID string
Name string
Summary string
Kind string
Required bool
Direct bool
Repeatable bool
Options []string
// contains filtered or unexported fields
}
PromptField IDs are "arg:<name>" for positionals and "flag:<name>" for flags.
type Prompter ¶ added in v0.1.68
type Prompter interface {
Prompt(cmd *cobra.Command, fields []PromptField) ([]PromptAnswer, error)
}