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

Conversation

jeffsmale90
Copy link
Contributor

@jeffsmale90 jeffsmale90 commented Apr 21, 2023

When ganache instances is executed, a subcommand must be provided.

Previously an unhelpful error was thrown, with this fix we output a simple error message, followed by the the help text for ganache instances.

$ ganache instances
ganache instances requires a subcommand:

ganache instances

Manage instances of Ganache running in detached mode.
(Ganache can be run in detached mode by providing the --detach flag)

Commands:
  ganache instances list         List instances running in detached mode
  ganache instances stop <name>  Stop the instance specified by <name>

Options:
  -?, --help  Show help                                                                           [boolean]

fixes: #4360

Comment on lines 287 to 291
const command = chalk`{hex("${TruffleColors.porsche}") ganache instances}`;
console.log(`${command} requires a subcommand:`);
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 :(

src/packages/cli/src/args.ts Outdated Show resolved Hide resolved
src/packages/cli/src/args.ts Show resolved Hide resolved
Co-authored-by: David Murdoch <187813+davidmurdoch@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Apr 25, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7ab20ae
Status: ✅  Deploy successful!
Preview URL: https://1caba4dd.ganache.pages.dev
Branch Preview URL: https://fix-instances-command-help.ganache.pages.dev

View logs

@jeffsmale90 jeffsmale90 merged commit 702b765 into develop Apr 26, 2023
@jeffsmale90 jeffsmale90 deleted the fix/instances_command_help branch April 26, 2023 01:05
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

fix/instances_command_help

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ganache instances should show a proper error message
2 participants