(flags *pflag.FlagSet)
| 147 | } |
| 148 | |
| 149 | func genFlagResult(flags *pflag.FlagSet) []cmdOption { |
| 150 | var result []cmdOption |
| 151 | |
| 152 | flags.VisitAll(func(flag *pflag.Flag) { |
| 153 | // Todo, when we mark a shorthand is deprecated, but specify an empty message. |
| 154 | // The flag.ShorthandDeprecated is empty as the shorthand is deprecated. |
| 155 | // Using len(flag.ShorthandDeprecated) > 0 can't handle this, others are ok. |
| 156 | if len(flag.ShorthandDeprecated) == 0 && len(flag.Shorthand) > 0 { |
| 157 | opt := cmdOption{ |
| 158 | flag.Name, |
| 159 | flag.Shorthand, |
| 160 | flag.DefValue, |
| 161 | forceMultiLine(flag.Usage), |
| 162 | } |
| 163 | result = append(result, opt) |
| 164 | } else { |
| 165 | opt := cmdOption{ |
| 166 | Name: flag.Name, |
| 167 | DefaultValue: forceMultiLine(flag.DefValue), |
| 168 | Usage: forceMultiLine(flag.Usage), |
| 169 | } |
| 170 | result = append(result, opt) |
| 171 | } |
| 172 | }) |
| 173 | |
| 174 | return result |
| 175 | } |
no test coverage detected