-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adjust sub-command template to properly output sub-sub-command placeholder. #1683
Conversation
I played around with this a bit and did not get it to produce different output than current main. Could you provide an example? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may not be sufficient since Help Command is added by default. So it really wont change any behaviour
@dearchap This is for when the help command is disabled. Then there are zero sub-commands (which is the use case where I encountered the problem). |
That makes sense. Can you see why the checks are failing ? You might have to run make v2approve or make v3approve |
@dearchap Running |
@aryounce I checked the output with the following program and there was no change from main to your PR. Maybe my example is incorrect? package main
import "github.com/urfave/cli/v3"
func main() {
app := &cli.App{
Name: "test",
Commands: []*cli.Command{
{
Name: "sub",
Commands: []*cli.Command{
{Name: "sub-sub", Hidden: true},
},
HideHelp: true,
},
},
}
_ = app.Run([]string{"test", "sub"})
} |
You need to run |
@avorima I've modified your example to demonstrate the issue I'm attempting to address. Be sure to run this outside of my branch (or off of package main
import (
"fmt"
"os"
"github.com/urfave/cli/v3"
)
func main() {
app := &cli.App{
Name: "test",
Commands: []*cli.Command{
{
Name: "default",
Action: dumpCmdInfo,
},
{
Name: "hide-help",
Action: dumpCmdInfo,
HideHelp: true,
},
{
Name: "hide-help-cmd",
Action: dumpCmdInfo,
HideHelpCommand: true,
},
{
Name: "hidden",
Action: dumpCmdInfo,
Hidden: true,
},
},
}
app.Run(os.Args)
}
func dumpCmdInfo(c *cli.Context) error {
fmt.Println(c.Command.Name)
fmt.Printf(" VisibleCommands() = %+v\n", c.Command.VisibleCommands())
fmt.Printf(" VisibleFlags() = %+v\n", c.Command.VisibleFlags())
return nil
} defaultWhen running the Help Output
Command Info Dump
hiddenThis uses Help Output
Command Info Dump
hide-helpHas no help output because the Command Info Dump
hide-help-cmdThis is the use case my PR is attempting to address. Although it has no sub-commands the help text output contains Help Output
Command Info Dump
|
Thank you, I can see the difference now. |
What type of PR is this?
What this PR does / why we need it:
template.go
includes an improper conditional in the sub-command help text template that relies on flag visibility instead command visibility for theCommand
instance.Which issue(s) this PR fixes:
Fixes #1682
Release Notes