_select

package
v0.37.1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2021 License: GPL-2.0, GPL-3.0 Imports: 8 Imported by: 0

README

select - User Selection Prompter

The select middleware shows a prompt in the terminal, allowing the user to make a selection from a pre-defined list of pipes. The selected pipe will the be executed.

Arguments

Options

The options argument is a list of pipeline references (either strings or maps) that the user will be able to choose from. The string shown to the user is either the contents of the description argument (if present and a string) or the pretty-printed identifier of the pipe.

Prompt

The prompt argument is an optional string shown to the user before selection. The default value is Please select an option.

Initial

The initial argument is an optional integer indicating the zero-based index of the initially selected item (before the user has pressed any buttons).

private:
    some-pipe:
        select:
            prompt: "Pick your poison!"
            initial: 1
            options:
                - some-pipe::option-1
                - some-pipe::option-2:
                    arg: value
                - some-pipe::option-3:
                    description "Choose me!"

will result in a prompt such as the following:

Pick your poison!
  Some Pipe > Child Pipe 1
> Some Pipe > Child Pipe 2
  Choose me!

Documentation

Overview

Package _select provides a middleware that shows a selection prompt to the user

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Middleware added in v0.32.2

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

Middleware is a user selection prompter

func NewMiddleware added in v0.32.2

func NewMiddleware() Middleware

NewMiddleware creates a new middleware instance

func NewMiddlewareWithStdinAndStdout added in v0.32.2

func NewMiddlewareWithStdinAndStdout(stdin io.ReadCloser, stdout io.WriteCloser) Middleware

NewMiddlewareWithStdinAndStdout creates a new middleware instance with the specified stdin and stdout

func (Middleware) Apply added in v0.32.2

func (selectMiddleware Middleware) Apply(
	run *pipeline.Run,
	next func(*pipeline.Run),
	executionContext *middleware.ExecutionContext,
)

Apply is where the middleware's logic resides

It adapts the run based on its slice of the run's arguments. It may also trigger side effects such as executing shell commands or full runs of other pipelines. When done, this function should call next in order to continue unwinding the stack.

func (Middleware) String added in v0.32.2

func (selectMiddleware Middleware) String() string

String is a human-readable description

Jump to

Keyboard shortcuts

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