MCPcopy
hub / github.com/tj/commander.js / visibleCommands

Method visibleCommands

lib/help.js:41–54  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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.

Callers 6

unknownCommandMethod · 0.80
formatHelpMethod · 0.80
index.test-d.tsFile · 0.80

Calls 2

_getHelpCommandMethod · 0.80
nameMethod · 0.45

Tested by

no test coverage detected