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

feat(cli): add command for reviewing a pr #130

Merged
merged 3 commits into from
Oct 6, 2020

Conversation

chingor13
Copy link
Contributor

No description provided.

@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Oct 5, 2020
@codecov
Copy link

codecov bot commented Oct 5, 2020

Codecov Report

Merging #130 into master will decrease coverage by 3.24%.
The diff coverage is 38.77%.

Impacted file tree graph

@@            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              
Impacted Files Coverage Δ
src/bin/code-suggester.ts 0.00% <0.00%> (ø)
src/bin/handle-git-dir-change.ts 73.17% <34.32%> (-12.35%) ⬇️
src/bin/workflow.ts 79.38% <66.66%> (-16.85%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d13a455...cd45fa6. Read the comment docs.

@chingor13 chingor13 marked this pull request as ready for review October 5, 2020 21:05
@chingor13 chingor13 requested a review from a team October 5, 2020 21:05
@chingor13 chingor13 requested a review from a team as a code owner October 5, 2020 21:05
@chingor13 chingor13 changed the title feat: add command for reviewing a pr feat(cli): add command for reviewing a pr Oct 5, 2020
Copy link
Contributor

@bcoe bcoe left a 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', {
Copy link
Contributor

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

Copy link
Contributor Author

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:
Copy link
Contributor

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

@chingor13 chingor13 merged commit ffac451 into googleapis:master Oct 6, 2020
@chingor13 chingor13 deleted the cli branch October 6, 2020 04:29
gcf-merge-on-green bot pushed a commit that referenced this pull request Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants