-
Notifications
You must be signed in to change notification settings - Fork 18
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
feat(cli): add command for reviewing a pr #130
Conversation
Codecov Report
@@ Coverage Diff @@
## master #130 +/- ##
==========================================
- Coverage 91.41% 88.17% -3.25%
==========================================
Files 25 25
Lines 2248 2384 +136
Branches 160 180 +20
==========================================
+ Hits 2055 2102 +47
- Misses 192 281 +89
Partials 1 1
Continue to review full report at Codecov.
|
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.
Left a few nits, regarding how you could potentially DRY up the CLI a bit.
yargs has built in support for commands, so you shouldn't need to implement a switch statement yourself, for instance.
@@ -94,6 +94,32 @@ yargs | |||
type: 'boolean', | |||
}, | |||
}) | |||
.command(REVIEW_PR_COMMAND, 'Review an open pull request', { |
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.
You should be able to describe all of the commands options inside its own JavaScript file, rather than here, see:
https://github.com/yargs/yargs/blob/master/docs/advanced.md#providing-a-command-module
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.
Filing #133 to clean up separately as it actually appears non-trivial with typing.
await createPullRequest(octokit, changes, options, logger); | ||
createCommand(); | ||
break; | ||
case REVIEW_PR_COMMAND: |
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.
You can get pretty fancy and provide a handler to the command itself, rather than using a switch like this:
.command('command', 'description of command', (yargs) => {
yargs.option('foo', {
type: 'string'
})
}, (argv) => {
// this code runs when the command is invoked.
})
Here's an example of a really fancy command line application built with yargs, that encapsulates commands in their own files:
https://github.com/redwoodjs/redwood/tree/main/packages/cli/src/commands
🤖 I have created a release \*beep\* \*boop\* --- ## [1.7.0](https://www.github.com/googleapis/code-suggester/compare/v1.6.0...v1.7.0) (2020-10-07) ### Features * **action:** action can now review pull requests ([#135](https://www.github.com/googleapis/code-suggester/issues/135)) ([c90a128](https://www.github.com/googleapis/code-suggester/commit/c90a128bb4e808ed3a1a8212eb4aac2e1179792d)) * **cli:** add command for reviewing a pr ([#130](https://www.github.com/googleapis/code-suggester/issues/130)) ([ffac451](https://www.github.com/googleapis/code-suggester/commit/ffac45171c68f67c75858866c51cb0dec9993141)) ### Bug Fixes * **action:** default upstream owner/repo to the current repo ([#131](https://www.github.com/googleapis/code-suggester/issues/131)) ([3dd762a](https://www.github.com/googleapis/code-suggester/commit/3dd762a49f6c42b6a652f3420d842a43f3744c3f)), closes [#73](https://www.github.com/googleapis/code-suggester/issues/73) * handle single line comments and add newline ([#128](https://www.github.com/googleapis/code-suggester/issues/128)) ([1526a40](https://www.github.com/googleapis/code-suggester/commit/1526a40de4d18765fc9343356f2be70e9af068a2)) * range parsing ([#125](https://www.github.com/googleapis/code-suggester/issues/125)) ([4993d62](https://www.github.com/googleapis/code-suggester/commit/4993d62f3e37d23b3cda83516c2dc6879464132f)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please).
No description provided.