printer

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

© Ben Garrett https://github.com/bengarrett/dupers

Index

Constants

View Source
const (
	Eraser      = "\u001b[2K" // Erase is an ANSI control code to erase the current line in stdout.
	CursorUp    = "\x1b[1A"   // CursorUp is an ANSI control to move the cursor up one line.
	MatchPrefix = "\n  ⤷\t"   // MatchPrefix is the prefix that's applied to dupe matches.

)

Variables

This section is empty.

Functions

func AskYN

func AskYN(question string, alwaysYes bool, recommend YN) bool

AskYN prints the question to stdout and prompts for a yes or no reply. The prompt will loop unless a y or n value is given or Ctrl-C is pressed. alwaysYes will display the question but automatically input "y" onbehalf of the user.

func Debug

func Debug(flag bool, s string)

Debug prints the string to a newline whenever the value of flag is true.

func EnterKey

func EnterKey() byte

EnterKey returns the Enter keyboard code.

func EraseLine

func EraseLine() string

EraseLine uses ANSI to erase the current line in stdout.

func ErrFatal

func ErrFatal(err error)

ErrFatal prints the error and exits the program.

func Example

func Example(cmd string)

Example is intended for help screens and prints the example command.

func Prompt

func Prompt(question string) string

Prompt prints the question to stdout and prompts for a string reply. The prompt will loop until Enter key or Ctrl-C are pressed.

func Quiet

func Quiet(flag bool, s string)

Quiet prints the string when the flag value is false.

func Status

func Status(count, total int, m Mode) string

Status prints out the current file or item processing count.

func Stderr

func Stderr(err error)

Stderr prints the formatted err to stderr.

func StderrCR

func StderrCR(err error)

StderrCR prints the formatted err to the current line of stderr.

Types

type Mode

type Mode uint

Mode for the current processing count.

const (
	Check Mode = iota // Check returns Checking items.
	Look              // Look returns Looking up items.
	Scan              // Scan returns Scanning files.
	Read              // Read returns Reading items.
)

type YN

type YN uint

YND is the YN default value to use when there is no input given.

const (
	Nil YN = iota // Nil does not set a default value.
	Yes           // Yes sets the default value.
	No            // No sets the default value.
)

func (YN) Define

func (y YN) Define() (prompt string, suffix string)

Define returns the prompt and suffix strings to print for a Yes or No prompt.

Jump to

Keyboard shortcuts

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