Skip to content

Improve error handling and output readability for CLI commands #1612

@ivanvpetrov

Description

@ivanvpetrov

Summary

When certain ig commands are run incorrectly (e.g., missing required sub-commands or arguments),
the CLI currently outputs raw exception stack traces to the user. This is noisy, unhelpful, and
presents a poor developer experience.

Current Behavior

Running ig generate without a sub-command produces output like:

Image

The full yargs internal stack trace is printed in red, even though this is an expected user error
(missing required sub-command), not an unexpected runtime exception.

Expected Behavior

  • Known/expected errors (e.g., missing sub-command, invalid arguments) should display a clean,
    actionable message — no stack trace.
  • Unexpected runtime errors may still show a stack trace for debugging, but ideally gated behind
    a --verbose or --debug flag.
  • Error messages should guide the user toward the correct usage, e.g.:
Error: Please provide a sub-command for "generate".
Usage: ig generate template [name]

Run "ig generate --help" for available options.

Suggested Improvements

  • Distinguish between YError (yargs validation errors / expected user mistakes) and actual
    runtime exceptions in the parseAsync callback in cli.ts.
  • Suppress stack traces for YError instances.
  • Append a usage hint or a pointer to --help when a command is used incorrectly.
  • Consider a --verbose flag to opt-in to full stack traces for debugging purposes.

Affected Area

  • packages/cli/lib/cli.tsparseAsync error callback
  • packages/cli/lib/commands/generate.tsdemandCommand error message
  • Potentially all commands using demandCommand or argument validation

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions