Documentation
¶
Index ¶
- Variables
- func NewHashCmd() *gcli.Command
- func NewMd5Cmd() *gcli.Command
- func NewProcessCmd() *gcli.Command
- func NewRandomStrCmd() *gcli.Command
- func NewReplaceCmd() *gcli.Command
- func NewStrMatchCmd() *gcli.Command
- func NewStringJoinCmd() *gcli.Command
- func NewTemplateCmd(mustFile bool) *gcli.Command
- func NewTextParseCmd() *gcli.Command
- func NewTextSearchCmd() *gcli.Command
- func NewUuidCmd() *gcli.Command
Constants ¶
This section is empty.
Variables ¶
View Source
var StrCountCmd = &gcli.Command{ Name: "length", Aliases: []string{"len", "count"}, Desc: "count input string length, with rune length, utf8 length, text width", Config: func(c *gcli.Command) { c.AddArg("text", "input text contents for process. allow @c,@FILE", true) }, Func: func(c *gcli.Command, _ []string) error { src, err := apputil.ReadSource(c.Arg("text").String()) if err != nil { return err } fmt.Printf( "raw length: %d\n - rune len: %d\n - utf8 len: %d\n - width: %d\n", len(src), len([]rune(src)), strutil.Utf8Len(src), strutil.TextWidth(src), ) return nil }, }
StrCountCmd instance
View Source
var StrSplitCmd = &gcli.Command{ Name: "split", Desc: "split input text to multi parts, then fetch or joins", Config: func(c *gcli.Command) { splitOpts.get.ValueFn = func(val int) error { return goutil.OrError(val >= 0, errorx.Raw("get index cannot be < 0")) } c.StrOpt2(&splitOpts.sep, "sep,s", "set sep char for split input. if not set, will auto detect available char.") c.VarOpt2(&splitOpts.get, "get, i", "get values by indexes, multi by comma") c.BoolOpt2(&splitOpts.inline, "inline", "inline output result, dont end with NL") c.StrOpt2(&splitOpts.join, "join", "set join char for build output", gflag.WithDefault("NL")) c.StrOpt2(&splitOpts.format, "format", "format output result, use $0, $1, ... $N") c.BoolOpt2(&splitOpts.noTrim, "no-trim", "do not trim input text contents") c.BoolOpt2(&splitOpts.noTrimItems, "no-trim-items", "do not trim each item contents") c.BoolOpt2(&splitOpts.count, "count, c", "count item number of split strings") c.BoolOpt2(&splitOpts.first, "first, 0", "get first part from split strings") c.BoolOpt2(&splitOpts.last, "last, l", "get last part from split strings") c.AddArg("text", "input text contents for handle. allow use: @c, @i").WithAfterFn(func(a *gflag.CliArg) error { splitOpts.text = a.String() return nil }) }, Func: strSplitHandle, Help: ` <green>### Sep Chars</>: NL - new line TAB - tab char SPACE - space char AS,anySpace - any space chars, like: space, tab, new line `, Examples: ` # custom output format {$binWithCmd} --last 'a b c' # Output: c {$binWithCmd} --first 'a b c' # Output: a {$binWithCmd} --format '$0,$2' 'a b c' # Output: a,c `, }
StrSplitCmd instance
View Source
var TextToolCmd = &gcli.Command{ Name: "text", Desc: "useful commands for handle string text", Aliases: []string{"txt", "str", "string"}, Subs: []*gcli.Command{ StrCountCmd, StrSplitCmd, NewStrMatchCmd(), NewTextParseCmd(), NewTextSearchCmd(), NewReplaceCmd(), NewMd5Cmd(), NewHashCmd(), NewUuidCmd(), NewRandomStrCmd(), NewStringJoinCmd(), NewTemplateCmd(false), convcmd.NewTime2dateCmd(), }, }
TextToolCmd instance
Functions ¶
func NewProcessCmd ¶
NewProcessCmd create a new ProcessCmd instance 实现处理输入文本内容
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.