-
Notifications
You must be signed in to change notification settings - Fork 73
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
fix: add exit codes to different flag validation errors #861
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@WillieRuemmele I think this needs to be configurable at the CLI level so we don't force all CLIs to use our standards. I'd like to keep oclif as un-opinionated as possible
I'm thinking that the CLI could have something like this in the package.json
{
"oclif": {
"exitCodes": {
"invalidArgs": 3,
"requiredFlag": 4,
// etc...
}
}
}
You might have an issue with accessing the root plugin's package.json from parser/validate.ts
. If so, you could consider putting all the exit codes on the Cache
class and then access them there - that way you don't have to pass around the package.json through multiple levels
39f4cc7
to
f6e4834
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved once comment stuff is cleaned up.
src/parser/parse.ts
Outdated
@@ -341,8 +341,10 @@ export class Parser< | |||
|
|||
return await flag.parse(input, ctx, flag) | |||
} catch (error: any) { | |||
error.message = `Parsing --${flag.name} \n\t${error.message}\nSee more help with --help` | |||
throw error | |||
// console.log(error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't leave the comments in
arg1: Args.string({ | ||
required: true, | ||
}), | ||
// qux: Args.string({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you need this?
QA notes: build oclif/core and run a command, then I think these are thrown from "inside" a command instead of during parse/validate and then we go customize the exitCodes prop
|
Turns out that exit codes beyond 255 aren't supported: https://www.shellscript.sh/exitcodes.html |
This is an issue with any command extending SfCommand. I'll have to fix that in a separate PR |
@W-14408666@
adds different exit codes (3-7) for different flag/args validation errors