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