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

fix: show a helpful message when ganache instances is executed without a subcommand #4368

Merged
merged 3 commits into from
Apr 26, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/packages/cli/src/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,17 @@ export default function (
}
)
.version(false);
},
function () {
// this handler executes when `ganache instances` is called without a subcommand
const command = chalk`{hex("${TruffleColors.porsche}") ganache instances}`;
console.log(`${command} requires a subcommand:`);
jeffsmale90 marked this conversation as resolved.
Show resolved Hide resolved
console.log();
yargs.showHelp();
yargs.exit(1, new Error("No subcommand provided"));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not my favourite. I'd rather use the .demandCommand() function, but this doesn't allow us to output the instances helptext, which I think is super useful.

This is also not easily testable, as it terminates the process inside of yargs :(

}
)
.showHelpOnFail(false, "Specify -? or --help for available options")
.showHelpOnFail(false)
davidmurdoch marked this conversation as resolved.
Show resolved Hide resolved
.alias("help", "?")
.wrap(wrapWidth)
.version(version);
Expand Down