utils

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func AreYouSure

func AreYouSure(message string, reader UserInputReader) bool

func Ask

func Ask(s string, required bool, secret bool, reader UserInputReader) string

func PrettyJSON

func PrettyJSON(b []byte) string
Example (Empty)
data := bytes.NewBufferString("").Bytes()
result := PrettyJSON(data)

fmt.Println(result)
Output:

Example (Notjson)
data := bytes.NewBufferString("<garbage>").Bytes()
result := PrettyJSON(data)

fmt.Println(result)
Output:

Example (Output)
data := bytes.NewBufferString("{\"cat\":\"meow\"}").Bytes()
result := PrettyJSON(data)

fmt.Println(result)
Output:

{
  "cat": "meow"
}

Types

type CommandRunner

type CommandRunner struct {
}

func (CommandRunner) RunCommand

func (cr CommandRunner) RunCommand(name string, arg ...string) error

type FileOps

type FileOps struct {
}

func (FileOps) FileExists

func (_ FileOps) FileExists(path string) bool

func (FileOps) ReadFile

func (_ FileOps) ReadFile(path string) ([]byte, error)

type StdinInputReader

type StdinInputReader struct{}

func NewStdinInputReader

func NewStdinInputReader() *StdinInputReader

func (StdinInputReader) Read

func (reader StdinInputReader) Read(secret bool) (string, error)

type UserInputReader

type UserInputReader interface {
	Read(secret bool) (string, error)
}

Jump to

Keyboard shortcuts

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