MCPcopy
hub / github.com/nestjs/nest / defineDefaultCommandsOnRepl

Function defineDefaultCommandsOnRepl

packages/core/repl/repl-native-commands.ts:20–50  ·  view source on GitHub ↗
(replServer: REPLServer)

Source from the content-addressed store, hash-verified

18}
19
20export function defineDefaultCommandsOnRepl(replServer: REPLServer): void {
21 replServer.defineCommand('help', {
22 help: 'Show REPL options',
23 action(name?: string) {
24 this.clearBufferedCommand();
25
26 if (name) {
27 // Considering native commands before native nestjs injected functions.
28 const nativeCommandOrFunction =
29 this.commands[name] || this.context[name];
30 // NOTE: If the command was retrieve from the context, it will have a `help`
31 // getter property that outputs the helper message and returns undefined.
32 // But if the command was retrieve from the `commands` object, it will
33 // have a `help` property that returns the helper message.
34 const helpMessage = nativeCommandOrFunction?.help;
35 if (helpMessage) {
36 this.output.write(`${helpMessage}\n`);
37 }
38 } else {
39 listAllCommands(this);
40 this.output.write('\n\n');
41 this.context.help();
42 this.output.write(
43 '\nPress Ctrl+C to abort current expression, Ctrl+D to exit the REPL\n',
44 );
45 }
46
47 this.displayPrompt();
48 },
49 });
50}

Callers 1

replFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected