interactive

package
v0.1.72-rc.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: MIT Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const PromptArgsAnnotation = "speakeasy_prompt_args"

Variables

This section is empty.

Functions

func Declare added in v0.1.68

func Declare(cmd *cobra.Command, spec CommandSpec) error

func Intercept added in v0.1.68

func Intercept(root *cobra.Command)

func IsInteractive

func IsInteractive(cmd *cobra.Command) bool

func WithPrompter added in v0.1.68

func WithPrompter(ctx context.Context, p Prompter) context.Context

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 Resolve added in v0.1.68

func Resolve(cmd *cobra.Command) Decision

func (Decision) AutoExplore added in v0.1.68

func (d Decision) AutoExplore() bool

func (Decision) FormMode added in v0.1.68

func (d Decision) FormMode() FormMode

func (Decision) PromptRequiredInputs added in v0.1.68

func (d Decision) PromptRequiredInputs() bool

func (Decision) ValidateDirectExplore added in v0.1.68

func (d Decision) ValidateDirectExplore() error

type FormMode added in v0.1.68

type FormMode int
const (
	FormOff FormMode = iota
	FormTUI
	FormAccessible
)

type PromptAnswer added in v0.1.68

type PromptAnswer struct {
	Set    bool
	Values []string
}

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

Jump to

Keyboard shortcuts

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