Skip to content

Commit

Permalink
up: cflag - update some comments for type
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Oct 16, 2022
1 parent f6ba94b commit 9027fde
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
21 changes: 11 additions & 10 deletions cflag/cflag.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ func SetDebug(open bool) {
//
// eg:
//
// // Can be set required and shorts on desc:
// // format1: desc;required
// cmd.IntVar(&age, "age", 0, "your age;true")
// // format2: desc;required;shorts
// cmd.IntVar(&age, "age", 0, "your age;true;a")
// // Can be set required and shorts on desc:
// // format1: desc;required
// cmd.IntVar(&age, "age", 0, "your age;true")
// // format2: desc;required;shorts
// cmd.IntVar(&age, "age", 0, "your age;true;a")
type CFlags struct {
*flag.FlagSet
// bound options.
Expand Down Expand Up @@ -77,14 +77,15 @@ type CFlags struct {
// New create new instance.
//
// Usage:
// cmd := cflag.New(func(c *cflag.CFlags) {
//
// cmd := cflag.New(func(c *cflag.CFlags) {
// c.Version = "0.1.2"
// c.Desc = "this is my cli tool"
// })
//
// // binding opts and args
// // binding opts and args
//
// cmd.Parse(nil)
// cmd.Parse(nil)
func New(fns ...func(c *CFlags)) *CFlags {
return NewEmpty(func(c *CFlags) {
c.FlagSet = flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
Expand Down Expand Up @@ -440,14 +441,14 @@ func (c *CFlags) showHelp(err error) {
buf.QuietWritef("<cyan>%s</>\n\n", c.helpDesc())
}

buf.QuietWritef("<comment>Usage:</> %s [--Options...] [...Arguments]\n", binName)
buf.QuietWritef("<comment>Usage:</> %s [--Options...] [...CliArgs]\n", binName)
buf.QuietWriteString("<comment>Options:</>\n")

// render options help
c.renderOptionsHelp(buf)

if len(c.bindArgs) > 0 {
buf.QuietWriteString("\n<comment>Arguments:</>\n")
buf.QuietWriteString("\n<comment>CliArgs:</>\n")
for _, arg := range c.bindArgs {
buf.QuietWritef(
" <green>%s</> %s\n",
Expand Down
4 changes: 2 additions & 2 deletions cflag/ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ func (s *EnumString) Set(value string) error {
// c.VarOpt(&names, "names", "", "multi name by comma split")
//
// --names "tom,john,joy"
// names.Split(",") -> []string{"tom","john","joy"}
// names.Split(",") -> []string{"tom","john","joy"}
//
// // case 2:
// var ids gcli.String
// c.VarOpt(&ids, "ids", "", "multi id by comma split")
//
// --names "23,34,56"
// names.Ints(",") -> []int{23,34,56}
// names.Ints(",") -> []int{23,34,56}
type String string

// Set value
Expand Down

0 comments on commit 9027fde

Please sign in to comment.