input

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const Name = "input"

Name of the service as used by workflows.

Variables

This section is empty.

Functions

This section is empty.

Types

type AskInput

type AskInput struct {
	Message string `json:"message,omitempty"` // prompt shown to the user
	Default string `json:"default,omitempty"` // fallback value if the user enters empty line
}

type AskOutput

type AskOutput struct {
	Text string `json:"text,omitempty"`
}

type Field

type Field struct {
	// Label displayed to the user (required).
	Label string `json:"label,omitempty"`
	// Name used as the key in the resulting map (defaults to Label if empty).
	Name string `json:"name,omitempty"`
	// Options – if provided – make this a single-choice (radio) field.  A user
	// can answer with either a number (1-N) corresponding to the option index
	// or by typing the option value verbatim (case-insensitive).
	Options []string `json:"options,omitempty"`
	// Default value returned when the user enters empty line.
	Default string `json:"default,omitempty"`
}

Field describes a single input element in a form.

type FormInput

type FormInput struct {
	Fields []Field `json:"fields,omitempty"`
	// Optional introductory message displayed before the form.
	Message string `json:"message,omitempty"`
}

type FormOutput

type FormOutput struct {
	Values map[string]string `json:"values,omitempty"`
}

type Service

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

Service implements types.Service and allows workflows to collect data from a user via standard input/output. Two methods are exposed:

ask   – free-form text prompt (single field)
form  – multi-field prompt with optional predefined choices (radio-style)

Tests can substitute Reader/Writer to avoid interactive TTY requirements.

func New

func New() *Service

New returns a Service that reads from stdin and writes to stdout.

func NewWithIO

func NewWithIO(in io.Reader, out io.Writer) *Service

NewWithIO lets callers override the input/output streams (handy for tests).

func (*Service) Method

func (s *Service) Method(name string) (types.Executable, error)

func (*Service) Methods

func (s *Service) Methods() types.Signatures

func (*Service) Name

func (s *Service) Name() string

Jump to

Keyboard shortcuts

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