* Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one. * * @param {Command} cmd * @returns {Command[]}
(cmd)
| 39 | */ |
| 40 | |
| 41 | visibleCommands(cmd) { |
| 42 | const visibleCommands = cmd.commands.filter((cmd) => !cmd._hidden); |
| 43 | const helpCommand = cmd._getHelpCommand(); |
| 44 | if (helpCommand && !helpCommand._hidden) { |
| 45 | visibleCommands.push(helpCommand); |
| 46 | } |
| 47 | if (this.sortSubcommands) { |
| 48 | visibleCommands.sort((a, b) => { |
| 49 | // @ts-ignore: because overloaded return type |
| 50 | return a.name().localeCompare(b.name()); |
| 51 | }); |
| 52 | } |
| 53 | return visibleCommands; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Compare options for sort. |
no test coverage detected