(
subcommands: ReadonlyArray<[Span.Span, Span.Span]>
)
| 397 | } |
| 398 | } |
| 399 | const printSubcommands = ( |
| 400 | subcommands: ReadonlyArray<[Span.Span, Span.Span]> |
| 401 | ): HelpDoc.HelpDoc => { |
| 402 | const maxUsageLength = Arr.reduceRight( |
| 403 | subcommands, |
| 404 | 0, |
| 405 | (max, [usage]) => Math.max(InternalSpan.size(usage), max) |
| 406 | ) |
| 407 | const documents = Arr.map(subcommands, ([usage, desc]) => |
| 408 | InternalHelpDoc.p( |
| 409 | InternalSpan.spans([ |
| 410 | usage, |
| 411 | InternalSpan.text(" ".repeat(maxUsageLength - InternalSpan.size(usage) + 2)), |
| 412 | desc |
| 413 | ]) |
| 414 | )) |
| 415 | if (Arr.isNonEmptyReadonlyArray(documents)) { |
| 416 | return InternalHelpDoc.enumeration(documents) |
| 417 | } |
| 418 | throw new Error("[BUG]: Subcommands.usage - received empty list of subcommands to print") |
| 419 | } |
| 420 | return InternalHelpDoc.sequence( |
| 421 | getHelpInternal(self.parent, config), |
| 422 | InternalHelpDoc.sequence( |
no test coverage detected