cli

package
v0.305.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package cli provides utilities for happy command line interfaces.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCommandInvalid = errors.New("invalid command definition")
	ErrCommandArgs    = errors.New("command arguments error")
	ErrCommandFlags   = errors.New("command flags error")
	ErrPanic          = errors.New("there was panic, check logs for more info")
)
View Source
var (
	FlagVersion     = varflag.BoolFunc("version", false, "com.github.happy-sdk.happy.sdk.cli.flags.version")
	FlagHelp        = varflag.BoolFunc("help", false, "com.github.happy-sdk.happy.sdk.cli.flags.help", "h")
	FlagX           = varflag.BoolFunc("show-exec", false, "com.github.happy-sdk.happy.sdk.cli.flags.show_exec", "x")
	FlagSystemDebug = varflag.BoolFunc("system-debug", false, "com.github.happy-sdk.happy.sdk.cli.flags.system_debug")
	FlagDebug       = varflag.BoolFunc("debug", false, "com.github.happy-sdk.happy.sdk.cli.flags.debug")
	FlagVerbose     = varflag.BoolFunc("verbose", false, "com.github.happy-sdk.happy.sdk.cli.flags.verbose", "v")
)

Common CLI flags which are automatically attached to the CLI ubnless disabled ins settings. You still can manually add them to your CLI if you want to.

View Source
var (
	FlagXProd = varflag.BoolFunc("x-prod", false, "com.github.happy-sdk.happy.sdk.cli.flags.x_prod")
)

FlagProd is a flag that forces the application into production mode.

Functions

func AskForConfirmation

func AskForConfirmation(q string) bool

AskForConfirmation gets (y/Y)es or (n/N)o from cli input.

func AskForInput

func AskForInput(q string) string

func AskForSecret

func AskForSecret(q string) string

func Exec added in v0.25.0

func Exec(sess *session.Context, cmd *exec.Cmd) (string, error)

Exec wraps ExecRaw to return output as string.

func ExecRaw added in v0.25.0

func ExecRaw(sess *session.Context, cmd *exec.Cmd) ([]byte, error)

ExecRaw wraps and executes provided command and returns its CombinedOutput. It ensures that -x flag is taken into account and Command is Session Context aware.

func Run added in v0.25.0

func Run(sess *session.Context, cmd *exec.Cmd) error

Run wraps and executes provided command and writes its Stdout and Stderr. It ensures that -x flag is taken into account and Command is Session Context aware.

Types

type Flag added in v0.100.0

type Flag = varflag.FlagCreateFunc

func NewBoolFlag added in v0.100.0

func NewBoolFlag(name string, value bool, usage string, aliases ...string) Flag

func NewDurationFlag added in v0.100.0

func NewDurationFlag(name string, value time.Duration, usage string, aliases ...string) Flag

func NewFloat64Flag added in v0.100.0

func NewFloat64Flag(name string, value float64, usage string, aliases ...string) Flag

func NewIntFlag added in v0.100.0

func NewIntFlag(name string, value int, usage string, aliases ...string) Flag

func NewOptionFlag added in v0.100.0

func NewOptionFlag(name string, value []string, opts []string, usage string, aliases ...string) Flag

func NewStringFlag added in v0.100.0

func NewStringFlag(name string, value string, usage string, aliases ...string) Flag

func NewUintFlag added in v0.100.0

func NewUintFlag(name string, value uint, usage string, aliases ...string) Flag

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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