Documentation ¶
Index ¶
- Constants
- func CallSudo(action string, params ...string) error
- func CliChoice(question string, choices []string) (int, error)
- func CliQuestion(question string) string
- func CliQuestionHidden(question string) (string, error)
- func CliQuestionYesNo(question string) bool
- func CliQuestionYesNoDefault(question string, defaultValue bool) bool
- func FormatData(data interface{}, format int) (string, error)
- func FormatToName(format int) string
- func GetAutoUpdate() (bool, error)
- func GetConfigDir() (string, error)
- func IsMissingData(err error) bool
- func LoadConfig(config string, data interface{}) error
- func LoadExternalConfig(filename string, data interface{}) error
- func LoadUserAuth() error
- func MergeAuth(base *types.RootAuth, overlay *types.RootAuth)
- func NameToFormat(name string) int
- func ParseData(data []byte, format int) (interface{}, error)
- func SaveConfig(config string, data interface{}) error
- func SaveExternalConfig(filename string, data interface{}) error
- func SaveUserAuth() error
- func SetAtPath(data *interface{}, path *[]interface{}, newData interface{}) error
- func SetAutoUpdate(shouldAutoUpdate bool) (bool, error)
- func TraversePath(data interface{}, path *[]interface{}) (interface{}, error)
- func TryAutoUpdateSelf() error
- func TryHandleSudo()
- func TryManualUpdate() error
Constants ¶
const ( // FormatUnknown represents an unknown data format FormatUnknown = iota // FormatText represents a raw string FormatText // FormatJSON represents data formatted as JSON FormatJSON // FormatYaml represents data formatted as YAML FormatYaml )
Variables ¶
This section is empty.
Functions ¶
func CallSudo ¶
CallSudo asks the user for superuser permissions, and then executes the currently-running program with those permissions for a particular action. TryHandleSudo should be called at the beginning of the program's main() function to catch these sudo calls.
func CliChoice ¶ added in v1.1.1
CliChoice provides an interactive UI to select between one or more choices
func CliQuestion ¶
CliQuestion prints a prompt to stdout and reads a line of input from stdin, returning that read string
func CliQuestionHidden ¶
CliQuestionHidden prints a prompt to stdout and reads a hidden line of input from stdin. This is meant to be used for passwords where you don't want them printed to the screen
func CliQuestionYesNo ¶
CliQuestionYesNo prints a question prompt and allows either yes or no answers to be entered, returning "y" or "yes" as true and "n" or "no" as false
func CliQuestionYesNoDefault ¶
CliQuestionYesNoDefault prints a question prompt and allows either yes or no answers to be entered, or no answer at all. If no answer is entered, the defaultValue is returned, otherwise "y" or "yes" returns true and "n" or "no" returns false
func FormatData ¶
FormatData formats the given value with the given format
func FormatToName ¶
FormatToName returns a text representation of a format code
func GetAutoUpdate ¶ added in v1.1.1
GetAutoUpdate gets if automatic updates are enabled
func GetConfigDir ¶
GetConfigDir gets the os-dependent user configuration directory
func IsMissingData ¶
IsMissingData returns true if the error is a missingDataError
func LoadConfig ¶
LoadConfig loads a user config file of the given name
func LoadExternalConfig ¶
LoadExternalConfig reads an external config file, outside of the default user config directory
func NameToFormat ¶
NameToFormat returns a number representation of a format name
func SaveConfig ¶
SaveConfig saves a user config file of the given name
func SaveExternalConfig ¶ added in v1.1.1
SaveExternalConfig saves a file outside of the default user config directory
func SetAtPath ¶
func SetAtPath(data *interface{}, path *[]interface{}, newData interface{}) error
SetAtPath is the write equivalent of TraversePath. It will write a subset of the given value with the given new data at the provided path. It will also create maps and arrays to reach the provided path if they don't exist, as well as filling out arrays with null values to make them long enough to fit a given path segment.
func SetAutoUpdate ¶ added in v1.1.1
SetAutoUpdate configures if automatic updates are enabled
func TraversePath ¶
func TraversePath(data interface{}, path *[]interface{}) (interface{}, error)
TraversePath takes a JSON-like value and recursively traverses it with a given list of keys. The result is a subset of that input value or an error
func TryAutoUpdateSelf ¶
func TryAutoUpdateSelf() error
TryAutoUpdateSelf checks for an update and replaces the existing executable with the new version if there is one. Update checks are debounced to every 24 hours, and can be disabled with a config option.
func TryHandleSudo ¶
func TryHandleSudo()
TryHandleSudo catches superuser self-executions to do certain actions that require superuser permissions
func TryManualUpdate ¶
func TryManualUpdate() error
TryManualUpdate checks for an update and replaces the existing executable with the new version if there is one. This will always run, without any debouncing or config options to disable it.
Types ¶
This section is empty.