Skip to content

Commit

Permalink
👔 up: update some for command help display format
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jan 20, 2023
1 parent 80dd56a commit ac59105
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ const (
// HookFunc definition.
//
// Returns:
// - True go on handle. default is True
// - False stop continue handle.
// - True for stop continue run.
// - False continue handle next logic.
type HookFunc func(ctx *HookCtx) (stop bool)

/*************************************************************
Expand Down
1 change: 0 additions & 1 deletion gflag/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ func (ops *CliOpts) checkShortNames(name string, shorts []string) {
// storage short name
ops.shorts[short] = name
}

}

/***********************************************************************
Expand Down
4 changes: 2 additions & 2 deletions gflag/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func (p *Parser) FromStruct(ptr any) error {

opt := newCliOpt(optName, mp["desc"], mp["default"], mp["shorts"])
if must, has := mp["required"]; has {
opt.Required = strutil.MustBool(must)
opt.Required = strutil.QuietBool(must)
}

// field is implements flag.Value
Expand Down Expand Up @@ -389,7 +389,7 @@ func (p *Parser) BuildHelp() string {
p.buf.WriteByte('\n')

if p.HasArgs() {
p.buf.WriteString("CliArgs:\n")
p.buf.WriteString("Arguments:\n")
p.buf.WriteString(p.BuildArgsHelp())
p.buf.WriteByte('\n')
}
Expand Down
4 changes: 2 additions & 2 deletions help.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ var CmdHelpTemplate = `{{.Desc}}
{{.GOpts}}{{end}}{{if .Options}}
<comment>Options:</>
{{.Options}}{{end}}{{if .Cmd.HasArgs}}
<comment>CliArgs:</>{{range $a := .Cmd.Args}}
<comment>Arguments:</>{{range $a := .Cmd.Args}}
<info>{{$a.HelpName | printf "%-12s"}}</> {{if $a.Required}}<red>*</>{{end}}{{$a.Desc | ucFirst}}{{end}}
{{end}}{{ if .Subs }}
<comment>Sub Commands:</>{{range $n,$c := .Subs}}
<comment>Subcommands:</>{{range $n,$c := .Subs}}
<info>{{$c.Name | paddingName }}</> {{$c.HelpDesc}}{{if $c.Aliases}} (alias: <green>{{ join $c.Aliases ","}}</>){{end}}{{end}}
{{end}}{{if .Cmd.Examples}}
<comment>Examples:</>
Expand Down

0 comments on commit ac59105

Please sign in to comment.