core

package
v1.0.0-alpha5 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2023 License: Unlicense Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EXIT_OK = iota
	EXIT_NEED_SUDO
	EXIT_INVALID_ARGS
	EXIT_MISSING_ARGS
	EXIT_TOO_MANY_ARGS
	EXIT_FILE_NOT_FOUND
	EXIT_DEVBOX_NOT_FOUND
	EXIT_REPO_CONNECTION_FAILED
	EXIT_REPO_DOWNLOAD_FAILED
	EXIT_REPO_UPLOAD_FAILED
	EXIT_REPO_CHECK_FAILED
	EXIT_WORKSPACE_PUSH_FAILED
	EXIT_WORKSPACE_PULL_FAILED
	EXIT_WORKSPACE_STORE_FAILED
	EXIT_WORKSPACE_RESTORE_FAILED
	EXIT_UNKNOWN_ERROR
	EXIT_UNKNOWN_FATAL
)
View Source
const (
	ERR_INVALID_ARGS     = "invalid args"
	ERR_MISSING_ARGS     = "missing required argument"
	ERR_TOO_MANY_ARGS    = "too many arguments"
	ERR_FILE_NOT_FOUND   = "no such file or directory"
	ERR_DEVBOX_NOT_FOUND = "devbox not found"
	ERR_FATAL            = "fatal error"
	CONFIG_FILE          = "config.yaml"
	START_SCRIPT_FILE    = "usr/local/bin/start"
	STOP_SCRIPT_FILE     = "usr/local/bin/stop"
	APP_NAME             = "devbox"
)
View Source
const (
	ARG_TYPE_DIR = iota
	ARG_TYPE_BOOL
	ARG_TYPE_FILE
	ARG_TYPE_TARBALL
	ARG_TYPE_IP
	ARG_TYPE_COMMAND
	ARG_TYPE_DEVBOX_LIST
	ARG_TYPE_WORKSPACE_LIST
	ARG_TYPE_SESSION_LIST
)

Variables

View Source
var (
	Config    = &config.Config{}
	AppConfig = &config.AppConfig{}

	ERRORS = map[string]error{}
	FATALS = map[string]error{}
)

Functions

func CheckError

func CheckError(err error)

CheckError will try to register the given error as a non-fatal error and then check if the given error matches a known one (which should always be the case). If err == nil the function will exit immediately.

func CheckFatal

func CheckFatal(err error)

CheckFatal will check if the given error is a fatal error and if so, it will exit with the registered exit code. If err == nil the function will exit immediately.

func CreateMissingDevboxFiles

func CreateMissingDevboxFiles(name string)

func FileExists

func FileExists(path string) bool

func FindCommand

func FindCommand(op string) *command

func ForceExit

func ForceExit(msg string, exitCode int)

func ForceFatal

func ForceFatal(msg string)

func GetCommandData

func GetCommandData() map[string][]bashcompletion.Completion

func GetCommandNames

func GetCommandNames() []string

func GetDevboxConfigPath

func GetDevboxConfigPath(name string) string

func GetDevboxDir

func GetDevboxDir() string

func GetDevboxPath

func GetDevboxPath(name string) string

func GetMaxCommandNameLength

func GetMaxCommandNameLength() int

func GetMaxCommandUsageLength

func GetMaxCommandUsageLength() int

func GetRepoDir

func GetRepoDir() string

func GetStorageDir

func GetStorageDir() string

func GetWorkspaceConfigPath

func GetWorkspaceConfigPath(name string) string

func GetWorkspaceDir

func GetWorkspaceDir() string

func GetWorkspacePath

func GetWorkspacePath(name string) string

func InitErrorRegistry

func InitErrorRegistry()

func ListCommands

func ListCommands()

func Must

func Must(err error, exclude ...string)

func RegisterCommand

func RegisterCommand(
	op string,
	help string,
	args ArgInfoList,
	run func(arg ...string) error,
)

func RegisterHiddenCommand

func RegisterHiddenCommand(
	op string,
	args ArgInfoList,
	run func(arg ...string) error,
)

Types

type ArgInfo

type ArgInfo struct {
	Optional       bool
	Variadic       bool
	Type           int
	Name           string
	Example        string
	OptionalSuffix string
}

func (*ArgInfo) Completion

func (ai *ArgInfo) Completion() bashcompletion.Completion

func (*ArgInfo) String

func (ai *ArgInfo) String() string

func (*ArgInfo) StringANSI

func (ai *ArgInfo) StringANSI() string

func (*ArgInfo) Strings

func (ai *ArgInfo) Strings() []string

type ArgInfoList

type ArgInfoList []ArgInfo

func (*ArgInfoList) Example

func (ail *ArgInfoList) Example() string

func (*ArgInfoList) NumArgs

func (ail *ArgInfoList) NumArgs() (min, max int)

func (*ArgInfoList) String

func (ail *ArgInfoList) String() string

func (*ArgInfoList) StringANSI

func (ail *ArgInfoList) StringANSI() string

Jump to

Keyboard shortcuts

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