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

generateUrl opens browser automatically #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mcamara
Copy link

@mcamara mcamara commented Sep 18, 2017

For lazy people (as me), copying and pasting the url is too much hassle. With this small fix, the url is automatically open in user's default browser.

Thanks for the good work!

@toniov
Copy link
Owner

toniov commented Sep 18, 2017

Thanks for the PR!

A couple of things:

  • Maybe it's not a good idea to open the browser without asking first (plus it would be a breaking change). Doing it through an option could be a better idea (something like $ gcal generateUrl -o.

  • It needs to be cross-platform, using opn it could be implemented easily.

@mcamara
Copy link
Author

mcamara commented Sep 18, 2017

You're right, I always forget windows users! I'll fix it later!

@mcamara
Copy link
Author

mcamara commented Sep 21, 2017

I've made the changes we talked about. What do you think now? 😸

const oauth2Client = getOauth2Client();
const authUrl = oauth2Client.generateAuthUrl({
access_type: 'offline',
scope: conf.SCOPES
});
console.log(authUrl);
if (openInBrowser) {
opn(authUrl, { wait: 0 });
Copy link
Owner

Choose a reason for hiding this comment

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

Since we don't wait for the page to be closed I don't think we need this wait option.

@@ -249,7 +253,7 @@ console.log(argv);
}
switch (command) {
case 'generateUrl': {
await generateUrl();
await generateUrl(argv.o);
Copy link
Owner

Choose a reason for hiding this comment

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

To keep it consistent with the other commands, it would be better to add the non-abbreviated form as well: (argv.open || argv.o).

@toniov
Copy link
Owner

toniov commented Sep 21, 2017

Thanks! Looks good!

Besides the comments, if you add the new option to help.js we are good to go I think!

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.

2 participants