(opts: Partial<Options<Required<UserProvidedArgs>>> = options)
| 325 | } |
| 326 | |
| 327 | export const optionDescriptions = (opts: Partial<Options<Required<UserProvidedArgs>>> = options): string[] => { |
| 328 | const entries = Object.entries(opts).filter(([, v]) => !!v.description) |
| 329 | const widths = entries.reduce( |
| 330 | (prev, [k, v]) => ({ |
| 331 | long: k.length > prev.long ? k.length : prev.long, |
| 332 | short: v.short && v.short.length > prev.short ? v.short.length : prev.short, |
| 333 | }), |
| 334 | { short: 0, long: 0 }, |
| 335 | ) |
| 336 | return entries.map(([k, v]) => { |
| 337 | const help = `${" ".repeat(widths.short - (v.short ? v.short.length : 0))}${v.short ? `-${v.short}` : " "} --${k} ` |
| 338 | return ( |
| 339 | help + |
| 340 | v.description |
| 341 | ?.trim() |
| 342 | .split(/\n/) |
| 343 | .map((line, i) => { |
| 344 | line = line.trim() |
| 345 | if (i === 0) { |
| 346 | return " ".repeat(widths.long - k.length) + (v.deprecated ? "(deprecated) " : "") + line |
| 347 | } |
| 348 | return " ".repeat(widths.long + widths.short + 6) + line |
| 349 | }) |
| 350 | .join("\n") + |
| 351 | (typeof v.type === "object" ? ` [${Object.values(v.type).join(", ")}]` : "") |
| 352 | ) |
| 353 | }) |
| 354 | } |
| 355 | |
| 356 | /** |
| 357 | * Parse arguments into UserProvidedArgs. This should not go beyond checking |
no outgoing calls
no test coverage detected