console

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package console contains helper functions for ending a program with a specific exit code and message.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fatal

func Fatal(exitCode int, v ...interface{})

Fatal terminates a program with a specific exit code and zero or more messages.

func Fatalf

func Fatalf(exitCode int, format string, v ...interface{})

Fatalf terminates a program with a specific exit code and zero or more messages formatted using a format string that's sent to the log and stderr.

func ReadDirectoryFlagValue

func ReadDirectoryFlagValue(flagName string, flagValue *string, isRequired bool, onErrorExitCode int) string

ReadDirectoryFlagValue tests whether the specified string refers to a directory. It ends the program with the specified exit code if an error occurs or if the required directory flag value does not refer to a directory.

func ReadFileFlagValue

func ReadFileFlagValue(flagName string, flagValue *string, isRequired bool, onErrorExitCode int) string

ReadFileFlagValue tests whether the specified string refers to a file. It ends the program with the specified exit code if an error occurs or if the required file flag value does not refer to a file.

func ReadRequiredFlagBaseURLValue

func ReadRequiredFlagBaseURLValue(flagName string, flagValue *string, onErrorExitCode int) url.URL

ReadRequiredFlagBaseURLValue returns the value of a required base URL flag. It returns the flag value for the specified flag and ends the program with the specified exit code if the flag value is not a valid URL.

func ReadRequiredFlagBoolValue

func ReadRequiredFlagBoolValue(flagName string, flagValue *bool, onErrorExitCode int) bool

ReadRequiredFlagBoolValue returns the value of a required bool flag. It returns the flag value for the specified flag and ends the program with the specified exit code if the flag value is missing.

func ReadRequiredFlagNonNegativeIntValue

func ReadRequiredFlagNonNegativeIntValue(flagName string, flagValue *int, onErrorExitCode int) int

ReadRequiredFlagNonNegativeIntValue returns the value of a required int flag. It returns the flag value for the specified flag and ends the program with the specified exit code if the flag value is negative.

func ReadRequiredFlagStringValue

func ReadRequiredFlagStringValue(flagName string, flagValue *string, onErrorExitCode int) string

ReadRequiredFlagStringValue returns the value of a required string flag. It returns the flag value for the specified flag and ends the program with the specified exit code if the flag value is not present.

func ReadStringCollectionValue

func ReadStringCollectionValue(flagValue *string) []string

ReadStringCollectionValue returns the value of a string collection flag. It returns the collection of values expressed with a semicolon separator character.

func ReadStringCollectionWithSeparatorValue

func ReadStringCollectionWithSeparatorValue(flagValue *string, sep string) []string

ReadStringCollectionWithSeparatorValue returns the value of a string collection flag. It returns the collection of values expressed using the specified separator character.

func ReadTextFileFlagValue

func ReadTextFileFlagValue(flagName string, flagValue *string, isRequired bool, onErrorExitCode int) string

ReadTextFileFlagValue returns the string in the specified file flag value. It returns the file contents as a trimmed string value and ends the program with the specified exit code if an error occurs.

func SetLogger

func SetLogger(flagName string, flagValue *string, teeToStdout bool, onErrorExitCode int) *os.File

SetLogger sets the output destination for the standard logger to the specified file flag value. It returns the log file and ends the program with the specified exit code if an error occurs.

Types

This section is empty.

Jump to

Keyboard shortcuts

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