util

package
v0.0.0-...-f8895a0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2013 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package util provides various utility functions. It also defines the following flags: --verbose, --debug, --silent, and --version

Index

Constants

This section is empty.

Variables

View Source
var (
	Fatal      func(v ...interface{})
	RunCommand = defaultRun
	OsExit     = os.Exit
	Cd         = defaultCd
)

Polymorphics to allow mocking in tests, these should always be set to their defaults except during testing

View Source
var (

	// OutputTarget is an io.Writer to write messages to, change it to a bytes.buffer to test output
	OutputTarget = os.Stderr
)

Functions

func CheckPath

func CheckPath(path string)

CheckPath causes the application to exit if path does not exist

func Debug

func Debug(s string)

Debug prints s id --debug is set

func DecreaseIndent

func DecreaseIndent()

DecreaseIndent decrements the indentation level used during PrintIndent calls

func Exists

func Exists(path string) (res bool)

Exists checks if a file or directory exists

func GetPath

func GetPath(p string) (path string)

GetPath processes p and returns a clean path ending in deps.json

func IncreaseIndent

func IncreaseIndent()

IncreaseIndent Increments the indentation level used during PrintIndent calls

func Mock

func Mock(w io.Writer)

Mock configures flags indentation and the logger for testing

func Parse

func Parse()

Parse command line flags

func Print

func Print(s string)

Print prints s unless --silent is set

func PrintDep

func PrintDep(name string, d dep.Dependency)

PrintDep displays a dependency based on the --silent and --verbose flags

func PrintIndent

func PrintIndent(s string)

PrintIndent prints s with indentation unless --silent is set

func Pwd

func Pwd() (pwd string)

Pwd returns the current working directory

func SetVerbose

func SetVerbose(v bool)

SetVerbose sets the verbose level for testing

func UpwardFind

func UpwardFind(dir string, file string) (found string)

UpwardFind searches for file starting in dir and moving up the path. Returns the path to the found file or the empty string if it was not found

func Verbose

func Verbose(s string)

Verbose prints s if --verbose is set

func VerboseIndent

func VerboseIndent(s string)

VerboseIndent prints s with indentation if --verbose is set

func Version

func Version(v string)

Version displays the version of depman and optionally exits (--version)

Types

This section is empty.

Jump to

Keyboard shortcuts

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