inertia: github.com/ubclaunchpad/inertia/cmd/core/utils/input Index | Files

package input

import "github.com/ubclaunchpad/inertia/cmd/core/utils/input"

Package input provides input parsing utilities for the Inertia CLI

Index

Package Files

doc.go input.go

Variables

var (
    // ErrEmptyInput is returned on empty imputs - toggle with AllowEmpty
    ErrEmptyInput = errors.New("empty input")
    // ErrInvalidInput is returned on disallowed inputs - toggle with AllowInvalid
    ErrInvalidInput = errors.New("invalid input")
)

func CatchSigterm Uses

func CatchSigterm(cancelFunc func())

CatchSigterm listens in the background for some kind of interrupt and calls the given cancelFunc as necessary

type PromptConfig Uses

type PromptConfig struct {
    AllowEmpty   bool
    AllowInvalid bool
}

PromptConfig offers prompt configuration

type PromptInteraction Uses

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

PromptInteraction is a builder for interactions - use .PromptX followed by .GetX

func NewPrompt Uses

func NewPrompt(conf *PromptConfig) *PromptInteraction

NewPrompt instantiates a new prompt interaction on standard in

func NewPromptOnInput Uses

func NewPromptOnInput(in io.Reader, conf *PromptConfig) *PromptInteraction

NewPromptOnInput instantiates a new prompt on specified input

func (*PromptInteraction) GetBool Uses

func (p *PromptInteraction) GetBool() (bool, error)

GetBool retrieves a boolean response based on "y" or "yes"

func (*PromptInteraction) GetString Uses

func (p *PromptInteraction) GetString() (string, error)

GetString retreives the raw string response from the prompt

func (*PromptInteraction) Prompt Uses

func (p *PromptInteraction) Prompt(query ...interface{}) *PromptInteraction

Prompt prints the given query and reads the response

func (*PromptInteraction) PromptFromList Uses

func (p *PromptInteraction) PromptFromList(optionName string, options []string) *PromptInteraction

PromptFromList creates a choose-one-from-x prompt

func (*PromptInteraction) Promptf Uses

func (p *PromptInteraction) Promptf(query string, args ...interface{}) *PromptInteraction

Promptf prints the given query and reads the response

Package input imports 8 packages (graph) and is imported by 10 packages. Updated 2020-04-02. Refresh now. Tools for package owners.