| 6 | const webPush = require('../src/index.js'); |
| 7 | |
| 8 | const printUsageDetails = () => { |
| 9 | const actions = [ |
| 10 | { |
| 11 | name: 'send-notification', |
| 12 | options: [ |
| 13 | '--endpoint=<url>', |
| 14 | '[--key=<browser key>]', |
| 15 | '[--auth=<auth secret>]', |
| 16 | '[--payload=<message>]', |
| 17 | '[--ttl=<seconds>]', |
| 18 | '[--encoding=<encoding type>]', |
| 19 | '[--vapid-subject=<vapid subject>]', |
| 20 | '[--vapid-pubkey=<public key url base64>]', |
| 21 | '[--vapid-pvtkey=<private key url base64>]', |
| 22 | '[--proxy=<http proxy uri, e.g: http://127.0.0.1:8889>]', |
| 23 | '[--gcm-api-key=<api key>]' |
| 24 | ] |
| 25 | }, { |
| 26 | name: 'generate-vapid-keys', |
| 27 | options: [ |
| 28 | '[--json]' |
| 29 | ] |
| 30 | } |
| 31 | ]; |
| 32 | |
| 33 | let usage = '\nUsage: \n\n'; |
| 34 | actions.forEach(action => { |
| 35 | usage += ' web-push ' + action.name; |
| 36 | usage += ' ' + action.options.join(' '); |
| 37 | usage += '\n\n'; |
| 38 | }); |
| 39 | |
| 40 | console.log(usage); |
| 41 | process.exit(1); |
| 42 | }; |
| 43 | |
| 44 | const generateVapidKeys = returnJson => { |
| 45 | const vapidKeys = webPush.generateVAPIDKeys(); |