| 157 | } |
| 158 | |
| 159 | func manPrintFlags(buf io.StringWriter, flags *pflag.FlagSet) { |
| 160 | flags.VisitAll(func(flag *pflag.Flag) { |
| 161 | if len(flag.Deprecated) > 0 || flag.Hidden { |
| 162 | return |
| 163 | } |
| 164 | format := "" |
| 165 | if len(flag.Shorthand) > 0 && len(flag.ShorthandDeprecated) == 0 { |
| 166 | format = fmt.Sprintf("**-%s**, **--%s**", flag.Shorthand, flag.Name) |
| 167 | } else { |
| 168 | format = fmt.Sprintf("**--%s**", flag.Name) |
| 169 | } |
| 170 | if len(flag.NoOptDefVal) > 0 { |
| 171 | format += "[" |
| 172 | } |
| 173 | if flag.Value.Type() == "string" { |
| 174 | // put quotes on the value |
| 175 | format += "=%q" |
| 176 | } else { |
| 177 | format += "=%s" |
| 178 | } |
| 179 | if len(flag.NoOptDefVal) > 0 { |
| 180 | format += "]" |
| 181 | } |
| 182 | format += "\n\t%s\n\n" |
| 183 | cobra.WriteStringAndCheck(buf, fmt.Sprintf(format, flag.DefValue, flag.Usage)) |
| 184 | }) |
| 185 | } |
| 186 | |
| 187 | func manPrintOptions(buf io.StringWriter, command *cobra.Command) { |
| 188 | flags := command.NonInheritedFlags() |