1
0
Fork 0
mirror of https://github.com/vbatts/go-mtree.git synced 2025-07-13 02:09:11 +00:00

go: go get -u ./... && go mod vendor && go mod tidy

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2023-10-07 09:59:06 -04:00
parent a9c6969125
commit e73ff94ef9
Signed by: vbatts
GPG key ID: E30EFAA812C6E5ED
162 changed files with 1835 additions and 2997 deletions

View file

@ -42,6 +42,7 @@ var helpCommand = &Command{
// 3 $ app foo
// 4 $ app help foo
// 5 $ app foo help
// 6 $ app foo -h (with no other sub-commands nor flags defined)
// Case 4. when executing a help command set the context to parent
// to allow resolution of subsequent args. This will transform
@ -77,6 +78,8 @@ var helpCommand = &Command{
HelpPrinter(cCtx.App.Writer, templ, cCtx.Command)
return nil
}
// Case 6, handling incorporated in the callee itself
return ShowSubcommandHelp(cCtx)
},
}
@ -206,9 +209,15 @@ func printFlagSuggestions(lastArg string, flags []Flag, writer io.Writer) {
func DefaultCompleteWithFlags(cmd *Command) func(cCtx *Context) {
return func(cCtx *Context) {
if len(os.Args) > 2 {
lastArg := os.Args[len(os.Args)-2]
var lastArg string
// TODO: This shouldnt depend on os.Args rather it should
// depend on root arguments passed to App
if len(os.Args) > 2 {
lastArg = os.Args[len(os.Args)-2]
}
if lastArg != "" {
if strings.HasPrefix(lastArg, "-") {
if cmd != nil {
printFlagSuggestions(lastArg, cmd.Flags, cCtx.App.Writer)
@ -292,8 +301,12 @@ func ShowSubcommandHelp(cCtx *Context) error {
if cCtx == nil {
return nil
}
HelpPrinter(cCtx.App.Writer, SubcommandHelpTemplate, cCtx.Command)
// use custom template when provided (fixes #1703)
templ := SubcommandHelpTemplate
if cCtx.Command != nil && cCtx.Command.CustomHelpTemplate != "" {
templ = cCtx.Command.CustomHelpTemplate
}
HelpPrinter(cCtx.App.Writer, templ, cCtx.Command)
return nil
}