Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to throw something to trigger logging message w/specific exit code, no stack trace #189

Open
cspotcode opened this issue Feb 3, 2023 · 0 comments

Comments

@cspotcode
Copy link

I would like to abort a CLI handler by throwing something, but control the exit code, and not see a stack trace.

I can think of two ways this might work:

a) ability to throw new CliError('message to log', exitCode)
b) optional errorHandler callback receives a thrown error and decides how to handle it. For example, any errors from an underlying http client can be logged in a specific format and exit with a specific exit code

I tried to use Exit for this, but it's not exported, and comments say it's an internal implementation detail of cmd-ts.

export class Exit {

I'm using runSafely, but I had to copy the implementation of run into my code, and it's undocumented. Could this be as simple as explaining runSafely in the README?

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

No branches or pull requests

1 participant