Allow explicitly setting boolean options in Go cli parser

Matches C parser
This commit is contained in:
Kovid Goyal
2025-04-28 11:54:51 +05:30
parent 39bf612071
commit d7fb143ee0
4 changed files with 45 additions and 12 deletions

View File

@@ -82,8 +82,10 @@ func (self *Option) FormatOptionForMan(output io.Writer) {
if self.IsList {
defval = ""
}
case BoolOption, CountOption:
case CountOption:
defval = ""
case BoolOption:
defval = utils.IfElse(self.Default == "true", "yes", "no")
}
if defval != "" {
@@ -111,7 +113,11 @@ func (self *Option) FormatOption(output io.Writer, formatter *markup.Context, sc
if self.IsList {
defval = ""
}
case BoolOption, CountOption:
case CountOption:
defval = ""
case BoolOption:
yn := utils.IfElse(self.Default == "true", "yes", "no")
fmt.Fprintf(output, " %s", formatter.Italic("[="+yn+"]"))
defval = ""
}
if defval != "" {