Documentation
¶
Overview ¶
Package cliutil provides some util functions for CLI
Index ¶
- Variables
- func BinDir() string
- func BinFile() string
- func BinName() string
- func Bluef(format string, a ...any)
- func Blueln(a ...any)
- func Bluep(a ...any)
- func BuildLine(binFile string, args []string) string
- func BuildOptionHelpName(names []string) string
- func ByteIsYes(ans byte) bool
- func CurrentShell(onlyName bool) (path string)
- func Cyanf(format string, a ...any)
- func Cyanln(a ...any)
- func Cyanp(a ...any)
- func Errorf(format string, a ...any)
- func Errorln(a ...any)
- func Errorp(a ...any)
- func ExecCmd(binName string, args []string, workDir ...string) (string, error)
- func ExecCommand(binName string, args []string, workDir ...string) (string, error)
- func ExecLine(cmdLine string, workDir ...string) (string, error)
- func GetTermSize(refresh ...bool) (w int, h int)
- func Grayf(format string, a ...any)
- func Grayln(a ...any)
- func Grayp(a ...any)
- func Greenf(format string, a ...any)
- func Greenln(a ...any)
- func Greenp(a ...any)
- func HasShellEnv(shell string) bool
- func Infof(format string, a ...any)
- func Infoln(a ...any)
- func Infop(a ...any)
- func InputIsYes(ans string) bool
- func LineBuild(binFile string, args []string) string
- func Magentaf(format string, a ...any)
- func Magentaln(a ...any)
- func Magentap(a ...any)
- func OutputLines(output string) []string
- func ParseLine(line string) []string
- func QuickExec(cmdLine string, workDir ...string) (string, error)
- func ReadFirst(question string) (string, error)
- func ReadFirstByte(question string) (byte, error)
- func ReadFirstRune(question string) (rune, error)
- func ReadInput(question string) (string, error)
- func ReadLine(question string) (string, error)
- func ReadPassword(question ...string) string
- func Redf(format string, a ...any)
- func Redln(a ...any)
- func Redp(a ...any)
- func ShellExec(cmdLine string, shells ...string) (string, error)
- func ShellQuote(s string) string
- func String2OSArgs(line string) []string
- func StringToOSArgs(line string) []string
- func Successf(format string, a ...any)
- func Successln(a ...any)
- func Successp(a ...any)
- func Warnf(format string, a ...any)
- func Warnln(a ...any)
- func Warnp(a ...any)
- func Workdir() string
- func Yellowf(format string, a ...any)
- func Yellowln(a ...any)
- func Yellowp(a ...any)
Constants ¶
This section is empty.
Variables ¶
View Source
var FirstLine = strutil.FirstLine
FirstLine from command output
Deprecated: please use strutil.FirstLine
View Source
var ( // Input global input stream Input io.Reader = os.Stdin )
the global input output stream
Functions ¶
func BuildOptionHelpName ¶
BuildOptionHelpName for render flag help
func CurrentShell ¶
CurrentShell get current used shell env file. eg "/bin/zsh" "/bin/bash"
func ExecCommand ¶
ExecCommand alias of the ExecCmd()
func GetTermSize ¶
GetTermSize for current console terminal.
func ReadFirstByte ¶
ReadFirstByte read first byte char
Usage:
ans, _ := cliutil.ReadFirstByte("continue?[y/n] ")
func ReadFirstRune ¶
ReadFirstRune read first rune char
func ReadLine ¶
ReadLine read one line from user input.
Usage:
in := cliutil.ReadLine("") ans, _ := cliutil.ReadLine("your name?")
func ShellQuote ¶
ShellQuote quote a string on contains ', ", SPACE
func String2OSArgs ¶
String2OSArgs parse input command line text to os.Args
func StringToOSArgs ¶
StringToOSArgs parse input command line text to os.Args
Types ¶
This section is empty.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.