diff --git a/examples/googleform/constants.js b/examples/googleform/constants.js new file mode 100644 index 00000000..65bd8820 --- /dev/null +++ b/examples/googleform/constants.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = { + FORM_ID: '1FAIpQLSdniaX5nAjywbvnT9tQp1OTryh7148Lkl5LnvJV1mBOy1QXdA' +}; diff --git a/examples/googleform/enquirer.js b/examples/googleform/enquirer.js new file mode 100644 index 00000000..031f5139 --- /dev/null +++ b/examples/googleform/enquirer.js @@ -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)); diff --git a/examples/googleform/prompt.js b/examples/googleform/prompt.js new file mode 100644 index 00000000..e04aad3d --- /dev/null +++ b/examples/googleform/prompt.js @@ -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)); diff --git a/examples/googleform/selectForm.js b/examples/googleform/selectForm.js new file mode 100644 index 00000000..3f6b6259 --- /dev/null +++ b/examples/googleform/selectForm.js @@ -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));