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
The output produced by WriteHelp and WriteManPage is inconsistent, and in particular WriteHelp seems wrong, when a command provides Usage().
Given
package main
import (
"fmt""os""github.com/jessevdk/go-flags"
)
typeOptsstruct {
Manpagebool`long:"man" hidden:"true"`
}
typeCmdOptsstruct {
Positionalstruct {
Foostring`positional-arg-name:"<foo>"`
} `positional-args:"yes"`
}
func (*CmdOpts) Usage() string { return"|<- this is the output of foo's Usage() ->|" }
funcmain() {
varoptsOptsp:=flags.NewParser(&opts, 0)
p.Usage="This is the toplevel usage."p.ShortDescription="toplevel short desc."p.LongDescription="This is the toplevel long description."varcmdOptsCmdOpts_, err:=p.AddCommand("foo", "foo short desc", "this is the foo's long description", &cmdOpts)
iferr!=nil {
fmt.Println(err)
os.Exit(1)
}
_, err=p.Parse()
iferr!=nil {
fmt.Println(err)
os.Exit(1)
}
ifopts.Manpage {
p.WriteManPage(os.Stdout)
} else {
p.WriteHelp(os.Stdout)
}
}
then in the manpage output, usage of the foo command includes some autogenerated toplevel usage followed by foo's usage,
$ ./test foo --man | COLUMNS=80 man -l - | cattroff: automatically ending diversion `an-div' on exittest(1) General Commands Manual test(1)NAME test - toplevel short desc.SYNOPSIS test This is the toplevel usage.DESCRIPTION This is the toplevel long description.OPTIONS Application OptionsCOMMANDS foo foo short desc this is the foo's long description Usage: test [OPTIONS] foo |<- this is the output of foo's Usage() ->|
$
but in the help output, usage of the foo command shows the manual toplevel usage, the command's usage, and some autogenerated usage bits:
$ ./test fooUsage: test This is the toplevel usage. foo |<- this is the output of foo's Usage() ->| [<foo>]this is the foo's long description
$
These can't be both right -- in fact I think they might both be wrong, in that I suspect what's needed is for there to be two different toplevel usages (one when used as part of a command usage, one standalone), and then the usage of a command is just the toplevel per-command usage + the command usage itself.
If that sounds right to you I could work on a patch for this.
The text was updated successfully, but these errors were encountered:
Is this an abandoned project, since 2018? Such an important feature has been broken for over 3 years. Gee, I should have checked here before I investigate my time in it, :( :(
The output produced by
WriteHelp
andWriteManPage
is inconsistent, and in particularWriteHelp
seems wrong, when a command providesUsage()
.Given
then in the manpage output, usage of the foo command includes some autogenerated toplevel usage followed by foo's usage,
but in the help output, usage of the foo command shows the manual toplevel usage, the command's usage, and some autogenerated usage bits:
These can't be both right -- in fact I think they might both be wrong, in that I suspect what's needed is for there to be two different toplevel usages (one when used as part of a command usage, one standalone), and then the usage of a command is just the toplevel per-command usage + the command usage itself.
If that sounds right to you I could work on a patch for this.
The text was updated successfully, but these errors were encountered: