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:prompt-google-form examples added #248

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions examples/googleform/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = {
FORM_ID: '1FAIpQLSdniaX5nAjywbvnT9tQp1OTryh7148Lkl5LnvJV1mBOy1QXdA'
};
28 changes: 28 additions & 0 deletions examples/googleform/enquirer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict';

const Enquirer = require('enquirer');
const GoogleFormPrompt = require('prompt-google-form');
const { FORM_ID } = require('./constants');

const enquirer = new Enquirer();
enquirer.register('google', GoogleFormPrompt);

enquirer
.prompt([
{
type: 'confirm',
name: 'confirm',
message: 'Would you like fill out our Survey?'
},
{
name: 'Google Form',
message: 'Please provide the information:',
formId: process.argv[2] || FORM_ID,
type: 'google',
skip() {
return this.state.answers.confirm !== true;
}
}
])
.then(res => console.log(res))
.catch(err => console.log(err));
14 changes: 14 additions & 0 deletions examples/googleform/prompt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

const GoogleFormPrompt = require('prompt-google-form');
const { FORM_ID } = require('./constants');

const prompt = new GoogleFormPrompt({
name: 'Google Form',
message: 'Please provide the information:',
formId: process.argv[2] || FORM_ID,
});

prompt.run()
.then(res => console.log(res))
.catch(err => console.log(err));
36 changes: 36 additions & 0 deletions examples/googleform/selectForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

const Enquirer = require('enquirer');
const GoogleFormPrompt = require('prompt-google-form');

const enquirer = new Enquirer();
enquirer.register('google', GoogleFormPrompt);

enquirer
.prompt([
{
type: 'select',
name: 'form',
message: 'Which Form Would you like to fill out?',
choices: [{
value: '1FAIpQLSdniaX5nAjywbvnT9tQp1OTryh7148Lkl5LnvJV1mBOy1QXdA',
message: 'Contact Form'
}, {
value: '1FAIpQLSfb_pdS57UJTS1qKaKfSLoDs9pudHLbNbkpp74kdpUYoEKz9Q',
message: 'T-Shirt Form'
}, {
value: '1FAIpQLSd5YEpcRFJAE47OuvHyI6equ66DEspA9S2AZHCafhokHUbjWg',
message: 'Event Form'
}]
},
{
name: 'Google Form',
message: 'Please provide the information:',
formId(state) {
return state.answers.form;
},
type: 'google'
}
])
.then(res => console.log(res))
.catch(err => console.log(err));