Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit b3f4507

Browse files
committed
core(cli): factor displayGeneralHelp to use isREPL context
1 parent 17cbe98 commit b3f4507

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

packages/core/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const inputArguments = process.argv.slice(2);
5151
// handle cases where input indicates the user wants to access Truffle's help
5252
const { displayHelp, inputStrings } = handleHelpInput({ inputArguments });
5353
if (displayHelp) {
54-
displayGeneralHelp({});
54+
displayGeneralHelp();
5555
process.exit();
5656
}
5757

packages/core/lib/command-utils.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ const { extractFlags } = require("./utils/utils"); // contains utility methods
55
const globalCommandOptions = require("./global-command-options");
66
const debugModule = require("debug");
77
const debug = debugModule("core:command:run");
8-
const { validTruffleCommands } = require("./commands/commands");
8+
const {
9+
validTruffleCommands,
10+
validTruffleConsoleCommands
11+
} = require("./commands/commands");
912
const Web3 = require("web3");
1013
const TruffleError = require("@truffle/error");
1114

@@ -294,8 +297,16 @@ const runCommand = async function (command, options) {
294297
return await command.run(options);
295298
};
296299

297-
const displayGeneralHelp = ({ commands = validTruffleCommands }) => {
300+
/**
301+
* Display general help for Truffle commands
302+
* @param {Object} options - options object
303+
* @param {Boolean} options.isREPL - whether or not the help is being displayed in a REPL
304+
* @returns {void}
305+
*/
306+
const displayGeneralHelp = options => {
298307
const yargs = require("yargs/yargs")();
308+
const isREPL = options?.isREPL ?? false; //default to not displaying REPL commands
309+
const commands = isREPL ? validTruffleConsoleCommands : validTruffleCommands;
299310
commands.forEach(command => {
300311
// Exclude "install" and "publish" commands from the generated help list
301312
// because they have been deprecated/removed.

packages/core/lib/console-child.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const {
88
displayGeneralHelp
99
} = require("./command-utils");
1010
const { handleHelpInput } = require("./cliHelp");
11-
const { validTruffleConsoleCommands } = require("./commands/commands");
1211

1312
// we split off the part Truffle cares about and need to convert to an array
1413
const input = process.argv[2].split(" -- ");
@@ -19,7 +18,7 @@ const inputArguments = parseQuotesAndEscapes(input[1], escapeCharacters); //note
1918
// handle cases where input indicates the user wants to access Truffle's help
2019
const { displayHelp, inputStrings } = handleHelpInput({ inputArguments });
2120
if (displayHelp) {
22-
displayGeneralHelp({ commands: validTruffleConsoleCommands });
21+
displayGeneralHelp({ isREPL: true });
2322
process.exit();
2423
}
2524

0 commit comments

Comments
 (0)