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

Run Yargs in strict mode and return exit code 1 if the command is invalid #518

Merged

Conversation

brushmate
Copy link
Contributor

Fixes #517

cli/index.ts Outdated
.fail((message, error) => {
console.log(error.stack);
if (message) {
console.log(message);
Copy link
Member

Choose a reason for hiding this comment

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

I would also pring yargs usage info here yargs.help()

@RomanHotsiy
Copy link
Member

RomanHotsiy commented May 29, 2018

Thanks, @brushmate! Could you please add usage help as per comment?

@coveralls
Copy link

coveralls commented May 29, 2018

Coverage Status

Coverage remained the same at 81.394% when pulling 4ee0f0f on yieldlab:show-error-when-subcommand-is-missing into 8e7f27b on Rebilly:master.

@brushmate
Copy link
Contributor Author

You are right. That would be nicer. I will do so tomorrow.

@brushmate brushmate force-pushed the show-error-when-subcommand-is-missing branch from 722a062 to 4ee0f0f Compare May 30, 2018 05:35
@brushmate
Copy link
Contributor Author

After reading more on Yargs I found out that positional parameters in the form of [param] are optional. To make them required they must look like <param>.

With the latest changes in this PR usage will be printed if the program was not called correctly. If an error happens in the business logic the stack is printed but not the usage. Exit code will be 1 in any case.

@RomanHotsiy RomanHotsiy merged commit 370d08a into Redocly:master May 31, 2018
@RomanHotsiy
Copy link
Member

Looks awesome! thank you!

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

Successfully merging this pull request may close these issues.

3 participants