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") c.StrOpt2(&splitOpts.join, "join", "set join char for build output, default is NL", gflag.WithDefault("NL")) c.VarOpt2(&splitOpts.get, "get, i", "get values by indexes, multi by comma") c.BoolOpt2(&splitOpts.noTrim, "no-trim", "do not trim input text contents") c.BoolOpt2(&splitOpts.count, "count, c", "count item number of split strings") c.BoolOpt2(&splitOpts.first, "first, f", "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").WithAfterFn(func(a *gflag.CliArg) error { splitOpts.text = a.String() return nil }) }, Func: strSplitHandle, Help: ` ### Sep chars: NL - new line TAB - tab char SPACE - space char AS,anySpace - any space chars, like: space, tab, new line `, }
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 ¶
func NewProcessCmd() *gcli.Command
NewProcessCmd create a new ProcessCmd instance
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.