util

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2021 License: Unlicense Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(name, usage string, dest *bool) *cli.BoolFlag

Bool returns an cli.BoolFlag

func BoolTrue

func BoolTrue(name, usage string, dest *bool) *cli.BoolTFlag

BoolTrue returns a CliBoolFlag that defaults to true

func Command

func Command(
	name string,
	usage string,
	action interface{},
	subcommands cli.Commands,
	flags []cli.Flag,
	aliases ...string,
) cli.Command

Command returns a cli.Command

func Dir

func Dir(appName string, roaming bool) string

Dir returns an operating system specific directory to be used for storing application data for an application. The appName parameter is the name of the application the data directory is being requested for. This function will prepend a period to the appName for POSIX style operating systems since that is standard practice.

An empty appName or one with a single dot is treated as requesting the current directory so only "." will be returned. Further, the first character of appName will be made lowercase for POSIX style operating systems and uppercase for Mac and Windows since that is standard practice.

The roaming parameter only applies to Windows where it specifies the roaming application data profile (%APPDATA%) should be used instead of the local one (%LOCALAPPDATA%) that is used by default. Example results:

dir := Dir("myapp", false)

 POSIX (Linux/BSD): ~/.myapp
 Mac OS: $HOME/Library/Application Support/Myapp
 Windows: %LOCALAPPDATA%\Myapp
 Plan 9: $home/myapp

func DownloadFile

func DownloadFile(directory string, url string, hashS string) (writtenFileName string, err error)

DownloadFile will download a url to a local file. It's efficient because it will write as it downloads and not load the whole file into memory.

func Duration

func Duration(name, usage string, value time.Duration, dest *time.Duration) *cli.DurationFlag

Duration returns an cli.DurationFlag

func EnsureDir

func EnsureDir(fileName string)

EnsureDir checks a file could be written to a path, creates the directories as needed

func FileExists

func FileExists(filePath string) bool

FileExists reports whether the named file or directory exists.

func Float64

func Float64(name, usage string, value float64, dest *float64) *cli.Float64Flag

Float64 returns an cli.Float64Flag

func GetDataDir

func GetDataDir(goos, appName string, roaming bool) string

GetDataDir returns an operating system specific directory to be used for storing application data for an application.

See Dir for more details. This unexported version takes an operating system argument primarily to enable the testing package to properly test the function by forcing an operating system that is not the currently one.

func Int

func Int(name, usage string, value int, dest *int) *cli.IntFlag

Int returns an cli.IntFlag

func Join

func Join(path, filename string) string

Join joins together a path and filename

func Lang

func Lang(name, usage, value string, dest *string) *cli.StringFlag

Lang returns an cli.StringFlag

func MinUint32

func MinUint32(a, b uint32) uint32

MinUint32 is a helper function to return the minimum of two uint32s. This avoids a math import and the need to cast to floats.

func PrependForWindows

func PrependForWindows(args []string) []string

func PrependForWindowsWithStart

func PrependForWindowsWithStart(args []string) []string

func String

func String(name, usage, value string, dest *string) *cli.StringFlag

String returns an cli.StringFlag

func StringSlice

func StringSlice(name, usage string, value *cli.StringSlice) *cli.StringSliceFlag

StringSlice returns and cli.StringSliceFlag

func SubCommands

func SubCommands(sc ...cli.Command) []cli.Command

SubCommands returns a slice of cli.Command

Types

This section is empty.

Jump to

Keyboard shortcuts

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