You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why is "help" special in that it'll ignore the Hidden property? It appears I can't hide "help" from the list of available commands because of this. Why????
Note that while I'm interested in knowing what the officially recommended way to get my desired results is (since the docs don't seem to mention it), I am honestly more interested in the design decision itself. As I see it:
"help" is so special to get this special treatment (by default it's a required sub-command that you can't hide) and yet the docs don't seem to mention this special-ness
we now have a situation where Hidden is basically ignored for the helpCmd. Yet there are ways around this (e.g. changing the usage template) so, the package has purposely decided to allow a way to get something done (hiding "help") but ONLY if you do something different from all other Commands and in the process make a flag/property (Hidden) 100% meaningless for a Command that's always there.
while changing the code so that Hidden is actually adhered to for the helpCmd seems like a potentially big change, the only people that would be impacted by it are those who (probably out of frustration) are currently setting Hidden to true and getting nothing out of it but really want to. I would consider it a bug in the user's code to be setting a flag that serves no purpose, so if Cobra was to change (for the better) it shouldn't actually be that big of an impact on existing code bases since they shouldn't be setting a pointless flag to begin with.
The text was updated successfully, but these errors were encountered:
My total guess is that it’s because I’d you don’t treat the help command special in the line you mention, then it will never be shown in the help text. If that is the case, then maybe the person who worked around this problem didn’t think about hiding the help command.
You’ll have to look at the commit introducing this problematic line to know for sure.
If you can figure out the history, it would be easy to tweak so that the help can be hidden.
Uh oh!
There was an error while loading. Please reload this page.
https://github.com/spf13/cobra/blob/ceb39aba25c86233e4888210c4b57cdb0a78d1e1/command.go#L1996C56-L1996C71 in particular the:
subcmd.Name() == helpCommandName
Why is "help" special in that it'll ignore the
Hidden
property? It appears I can't hide "help" from the list of available commands because of this. Why????Note that while I'm interested in knowing what the officially recommended way to get my desired results is (since the docs don't seem to mention it), I am honestly more interested in the design decision itself. As I see it:
Hidden
is basically ignored for the helpCmd. Yet there are ways around this (e.g. changing the usage template) so, the package has purposely decided to allow a way to get something done (hiding "help") but ONLY if you do something different from all other Commands and in the process make a flag/property (Hidden
) 100% meaningless for a Command that's always there.Hidden
is actually adhered to for the helpCmd seems like a potentially big change, the only people that would be impacted by it are those who (probably out of frustration) are currently settingHidden
totrue
and getting nothing out of it but really want to. I would consider it a bug in the user's code to be setting a flag that serves no purpose, so if Cobra was to change (for the better) it shouldn't actually be that big of an impact on existing code bases since they shouldn't be setting a pointless flag to begin with.The text was updated successfully, but these errors were encountered: