cli

package module
v0.0.0-...-8f4c7f0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 4 Imported by: 20

README

cli

Package of go utilties related to command line interface (CLI) applications.

installation

go get github.com/simonski/cli

building

make 

running

nope, it's libraries

Github

Use PRs, I have a github action for compile and test.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEnvOrDefault

func GetEnvOrDefault(key string, defaultValue string) string

GetEnvOrDefault returns an os.Getenv value or the defaultValue

Types

type CLI

type CLI struct {
	Args             []string
	IS_INTERACTIVE   bool
	IS_VERBOSE       bool
	IS_VERBOSE2      bool
	IS_VERBOSE3      bool
	IS_EXIT_ON_ERROR bool
}

CLI is my helper utility to work out what the user did type

func New

func New(args []string) *CLI

NewCLI create instance of a cli

func NewFromString

func NewFromString(line string) *CLI

func (CLI) Contains

func (c CLI) Contains(key string) bool

Contains indicates if a key exists or

func (CLI) FileExists

func (c CLI) FileExists(filename string) bool

FileExists asserts the filename exists and is a file

func (CLI) Flatten

func (c CLI) Flatten() string

func (*CLI) GetCommand

func (c *CLI) GetCommand() string

func (CLI) GetFileExistsOrDefault

func (c CLI) GetFileExistsOrDefault(key string, defaultValue string) string

GetFileExistsOrDefault returns the filename associated with the key or returns the defaultValue if the file does not exist

func (CLI) GetFileExistsOrDie

func (c CLI) GetFileExistsOrDie(key string) string

GetFileExistsOrDie returns the name of the file provided if it exists or failes and os.Exit(1)

func (CLI) GetFileExistsOrDieWithMessage

func (c CLI) GetFileExistsOrDieWithMessage(key string, message string) string

func (CLI) GetIntOrDefault

func (c CLI) GetIntOrDefault(key string, defaultValue int) int

GetIntOrDefault returns the int asssociated with the key or the defaultValue

func (CLI) GetIntOrDie

func (c CLI) GetIntOrDie(key string) int

GetIntOrDie returns the int value associated with the passed key or fails and os.Exit(1)

func (CLI) GetIntOrEnvOrDefault

func (c CLI) GetIntOrEnvOrDefault(key string, env_key string, defaultValue int) int

func (CLI) GetStringFromSetOrDefault

func (c CLI) GetStringFromSetOrDefault(key string, defaultValue string, permitted []string) string

func (CLI) GetStringFromSetOrDie

func (c CLI) GetStringFromSetOrDie(key string, permitted []string) string

func (CLI) GetStringOrDefault

func (c CLI) GetStringOrDefault(key string, defaultValue string) string

GetStringOrDefault returns the value associated with the key or the defaultValue if not present

func (CLI) GetStringOrDie

func (c CLI) GetStringOrDie(key string) string

GetStringOrDie requires the key exist in the CLI arguments or os.Exit(1)

func (CLI) GetStringOrEnvOrDefault

func (c CLI) GetStringOrEnvOrDefault(key string, env_key string, defaultValue string) string

func (CLI) GetStringOrEnvOrDie

func (c CLI) GetStringOrEnvOrDie(key string, env_key string) string

func (CLI) IndexOf

func (c CLI) IndexOf(key string) int

IndexOf find the position (or -1 if not present) in the args

func (*CLI) Shift

func (c *CLI) Shift()

func (CLI) SplitStringToFloats

func (c CLI) SplitStringToFloats(cols string, delim string) []float64

SplitStringToFloats splits the cols string based on the delimiter, converting the results in an []float64

func (CLI) SplitStringToInts

func (c CLI) SplitStringToInts(cols string, delim string) []int

SplitStringToInts splits the cols string based on the delimiter, converting the results in an []int

Jump to

Keyboard shortcuts

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