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

Commit

Permalink
add handling for truffle --help <cmd>
Browse files Browse the repository at this point in the history
  • Loading branch information
lsqproduction committed Nov 15, 2022
1 parent 24d4454 commit d97eb3f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/core/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ if (userWantsGeneralHelp) {
displayGeneralHelp();
process.exit(0);
}

//if the last word of inputString is `help` or `--help`, re-assign inputString to run as `truffle help <cmd>`
//clean up inputString to run as `truffle help <cmd>` if `help`, `--help` is present with a <cmd>
if (inputStrings.length > 1 && inputStrings[0] === "--help") {
inputStrings[inputStrings.indexOf("--help")] = "help";
}
if (["help", "--help"].includes(inputStrings[inputStrings.length - 1])) {
inputStrings.pop();
inputStrings.unshift("help");
Expand All @@ -73,7 +75,9 @@ const command = getCommand({
//getCommand() will return null if a command not recognized by truffle is used.
if (command === null) {
console.log(
`\`truffle ${inputStrings}\` is not a valid truffle command. Please see \`truffle help\` for available commands.`
`\`truffle ${inputStrings.join(
" "
)}\` is not a valid truffle command. Please see \`truffle help\` for available commands.`
);
process.exit(1);
}
Expand Down

0 comments on commit d97eb3f

Please sign in to comment.