Documentation
¶
Index ¶
- Constants
- func Completing(words []string) bool
- func Completion(shell string) ([]byte, error)
- func Helped(words []string) bool
- func OwnServer(ctx context.Context) bool
- func Pad(text string, n int) string
- func Painted(text string, codes ...string) string
- func Picked(set map[int]bool) []int
- func Width(text string) int
- func WithOwnServer(ctx context.Context) context.Context
- type CLI
- type Console
- func (c *Console) Agree(prompt string, def bool) bool
- func (c *Console) Answer(prompt string) (string, bool)
- func (c *Console) Ask(question string, def bool) bool
- func (c *Console) Attended() bool
- func (c *Console) Await(prompt string) <-chan Line
- func (c *Console) Blank()
- func (c *Console) Checklist(title string, items []string, selected map[int]bool) map[int]bool
- func (c *Console) Choose(title string, items []string) (int, bool)
- func (c *Console) Colored() bool
- func (c *Console) Confirm(question string, def bool) bool
- func (c *Console) Context() context.Context
- func (c *Console) Fail(text string) error
- func (c *Console) Failure(text string)
- func (c *Console) Index(prompt string, count int, empty bool, emptyLine string) (int, bool)
- func (c *Console) Info(text string)
- func (c *Console) Input(prompt string) (string, bool)
- func (c *Console) Interactive() bool
- func (c *Console) OnOff(on bool) string
- func (c *Console) Out() io.Writer
- func (c *Console) Paint(text string, codes ...string) string
- func (c *Console) Pairs(title string, rows [][2]string)
- func (c *Console) Panel(title string, lines ...string)
- func (c *Console) Prompt(question, def string, secret bool) string
- func (c *Console) Say(text string, codes ...string)
- func (c *Console) Secret(prompt string) (string, bool)
- func (c *Console) Step(n int, title string)
- func (c *Console) Success(text string)
- func (c *Console) Table(headers []string, rows [][]string)
- func (c *Console) Tick() string
- func (c *Console) Took()
- func (c *Console) Warning(text string)
- func (c *Console) YesNo(on bool) string
- type Exit
- type Line
- type Registrant
- type Registry
Constants ¶
const ( GroupSessions = "sessions" GroupModels = "models" GroupAbilities = "abilities" GroupSafety = "safety" GroupSecrets = "secrets" GroupApp = "app" GroupMore = "more" )
Groups the root's help lists its commands under, most used first; a command that names none is listed under More
const ( Cyan = "\033[36m" Green = "\033[32m" Yellow = "\033[33m" Red = "\033[31m" Dim = "\033[2m" Bold = "\033[1m" Gray = "\033[90m" Reset = "\033[0m" )
Colors of a console's lines
Variables ¶
This section is empty.
Functions ¶
func Completing ¶
Whether the words are a shell asking for completions as the person presses tab, which the completion scripts do
func Completion ¶
Script that lets a shell complete icebath's commands, flags and arguments as the person presses tab, asking icebath for them, as the completion command prints it: for bash (through bash-completion), zsh, fish or powershell
func OwnServer ¶
Whether the command runs against the server of its own process, so nothing it leaves in that server's memory outlives the command
Types ¶
type CLI ¶
type CLI struct {
Registry
// contains filtered or unexported fields
}
type Console ¶
type Console struct {
// contains filtered or unexported fields
}
Terminal of one command: lines in color when it is a terminal, answers read one line at a time, secrets without echo, at most one read outstanding
func NewConsole ¶
func Terminal ¶
Console of this process's own terminal, for a hook that runs around a command rather than in one
func (*Console) Agree ¶
Yes or no from one line after the prompt as given: y or yes is yes, an empty line, the end of the input or an interrupt the default
func (*Console) Answer ¶
Line typed after the prompt without its surrounding spaces, false at the end of the input or on an interrupt
func (*Console) Ask ¶
Confirm of a wizard: the question indented and in yellow, its hint followed by a colon
func (*Console) Await ¶
Line typed after the prompt, read while the caller waits on other things, joining a read already outstanding; Took is called once it came
func (*Console) Checklist ¶
Items checked and unchecked by their numbers until the list is accepted; the picked ones, the selection given when cancelled
func (*Console) Colored ¶
Whether the lines go to a terminal that shows color, which redraws a line in place too
func (*Console) Confirm ¶
Yes or no from one line after the question and its y/N hint, the default on an empty line, the end of the input or an interrupt
func (*Console) Index ¶
Number from 1 to count typed after the prompt, asked again until one is; 0 for an empty line when empty is allowed, false at the end of the input
func (*Console) Info ¶
Lines of a wizard: a note, a step done, a warning and a failure, each indented and marked
func (*Console) Input ¶
Line typed after the prompt, false at the end of the input or on an interrupt
func (*Console) Interactive ¶
Whether a person answers at a terminal
func (*Console) Pairs ¶
Prints labels and values in two columns, the labels in bold, under a title in a frame
func (*Console) Prompt ¶
Answer of a wizard to the question, indented and in yellow with its default when it is no secret; the default when nothing is typed
func (*Console) Secret ¶
Line typed after the prompt without echo where the input is a terminal, false at the end of the input or on an interrupt
func (*Console) Table ¶
Prints a table: the headers in bold over a rule, then each row, every column as wide as its widest cell