Documentation ¶
Index ¶
- Constants
- func Download(url, saveDir string, rename ...string) error
- func GetTerminalSize(refresh ...bool) (w int, h int)
- func IsGoodCmdId(name string) bool
- func IsGoodCmdName(name string) bool
- func IsGoodName(name string) bool
- func Panicf(format string, v ...any)
- func RenderText(input string, data any, fns template.FuncMap, isFile ...bool) string
- func SimpleDownload(url, saveAs string) (err error)
- type Downloader
- type HelpVars
Constants ¶
View Source
const ( // RegGoodName match a good option, argument name RegGoodName = `^[a-zA-Z][\w-]*$` // RegGoodCmdName match a good command name RegGoodCmdName = `^[a-zA-Z][\w-]*$` // RegGoodCmdId match command id. eg: "self:init" RegGoodCmdId = `^[a-zA-Z][\w:-]*$` )
View Source
const HelpVarFormat = "{$%s}"
HelpVarFormat allow var replace on render help info.
Default support:
"{$binName}" "{$cmd}" "{$fullCmd}" "{$workDir}"
Variables ¶
This section is empty.
Functions ¶
func Download ¶
Download file from remote URL. from https://gist.github.com/albulescu/e61979cc852e4ee8f49c
func GetTerminalSize ¶
GetTerminalSize for current console terminal.
func RenderText ¶
RenderText render text template with data. TODO use strutil.RenderText()
func SimpleDownload ¶
SimpleDownload simple download
Types ¶
type Downloader ¶
type Downloader struct { FileURL string SaveDir string Filename string // save file name. Progress bool // display progress info // contains filtered or unexported fields }
Downloader struct definition. refer: https://gist.github.com/albulescu/e61979cc852e4ee8f49c
type HelpVars ¶ added in v3.1.0
type HelpVars struct {
VarOpen, VarClose string
// Vars you can add some vars map for render help info. TODO rename replaces/pairs
Vars map[string]string
}
HelpVars struct. provide string var function for render help template.
func (*HelpVars) ReplaceVars ¶ added in v3.1.0
ReplaceVars replace vars in the input string.
Click to show internal directories.
Click to hide internal directories.