prompter

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package prompter is a small state machine for manipulating the terminal output during `bud run`.

The public methods must be called in the right order:

  1. Init
  2. Reloading
  3. SuccessReload or FailReload or NoReload
  4. Reloading

So the cursor can moves and clear lines properly. The behavior of the cursor across the different states looks like the following:

| Ready | Reloading | Ready Again | | :------------ | :------------------- | :------------ | | $ Ready on... | $ _Reloading... | $ Ready on... | | _ | (move cursor up) | _ |

TODO: find a better name for this package. Prompter sounds like it's reading user input from stdin, whereas this package is about managing `bud run` state and updating the terminal accordingly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Prompter

type Prompter struct {
	Counter int

	// Prevent overriding stdout and stderr
	StdOut bytes.Buffer
	StdErr bytes.Buffer
	// contains filtered or unexported fields
}

For prompting messages in the terminal

func (*Prompter) FailReload

func (p *Prompter) FailReload(err string)

Prompt failed reloads. Reset counter.

func (*Prompter) Init

func (p *Prompter) Init(listeningAddress string)

func (Prompter) NoReload

func (p Prompter) NoReload()

Don't change reload message currently in the terminal

func (*Prompter) Reloading

func (p *Prompter) Reloading(events []watcher.Event)

Prompt "Reloading..." message. Start timer.

func (*Prompter) SuccessReload

func (p *Prompter) SuccessReload()

Prompt successful reloads including time (in ms) and total times in a row. Increase counter. Example: Ready on http://127.0.0.1:3000 in 264ms (x141)

Jump to

Keyboard shortcuts

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