io

package
v0.0.0-...-a80f706 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateShell

func CreateShell() (*shell, error)

func NewBashShell

func NewBashShell() *shell

func NewFilesystem

func NewFilesystem() *filesystem

func NewShShell

func NewShShell() *shell

func NewTerminal

func NewTerminal() *terminal

func PrintVerbose

func PrintVerbose(verbose bool, result string, err error)

func PrintVerboseError

func PrintVerboseError(verbose bool, err error)

func PrintVerboseF

func PrintVerboseF(verbose bool, format string, args ...interface{})

Types

type Downloader

type Downloader interface {
	Download(ctx context.Context, from, to string) (string, error)
}

type Filesystem

type Filesystem interface {
	//Detects if the file already links to the appropriate location, which becomes a NOP.
	//If a file exists at the target location, it gets moved to the backup location
	CreateSymlink(from, to, backup string) error
	Stat(name string) (os.FileInfo, error)
	// IsSymlinkTo detects if the file at `from` symlinks to `to`
	IsSymlinkTo(from, to string) (bool, error)
	//Move(from, to string) error
	ReadFile(filename string) ([]byte, error)
}

type LogLevel

type LogLevel string
const (
	Informational LogLevel = "informational"
	Warning       LogLevel = "warning"
	Error         LogLevel = "error"
)

type Logger

type Logger interface {
	Infof(format string, args ...interface{})
	Warningf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Debugf(format string, args ...interface{})
}

func NewLogger

func NewLogger() Logger

type Shell

type Shell interface {
	Run(ctx context.Context, printOnly bool, cmdLine string) (string, error)
	// Runs `which` on the target shell, to determine if a program exists or not.
	Which(ctx context.Context, search string) (bool, string, error)
}

type Terminal

type Terminal interface {
	Logger
	//PromptUser prompts the user to select any of the given options, with the specific option
	PromptUser(prompt string, options []string, defaultSelection string) (string, error)
	//Tightly coupled interface just so we can moq it
	AskOne(p survey.Prompt, response interface{}, opts ...survey.AskOpt) error
}

Terminal A terminal/shell with user, to prompt questions from user and print/log

Jump to

Keyboard shortcuts

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