1 | 'use strict';
|
2 |
|
3 |
|
4 |
|
5 | const create = require('../lib/create');
|
6 |
|
7 |
|
8 |
|
9 | const INTERACTION = 'interaction';
|
10 | const RESOURCE_TYPES = [ INTERACTION ];
|
11 | const INTERACTION_MADL = 'madl';
|
12 | const DEFAULT_INTERACTION_TYPE = INTERACTION_MADL;
|
13 | const INTERACTION_TYPES = [ INTERACTION_MADL, 'message' ];
|
14 |
|
15 | module.exports = function (input, flags, options) {
|
16 | const resourceType = input[0];
|
17 | const name = input[1];
|
18 |
|
19 | if (!~RESOURCE_TYPES.indexOf(resourceType)) {
|
20 | console.error(`provide a supported resource: ${RESOURCE_TYPES.join(', ')}`);
|
21 | process.exit(1);
|
22 | }
|
23 |
|
24 | let subType;
|
25 |
|
26 | if (resourceType === INTERACTION) {
|
27 | subType = flags.type || DEFAULT_INTERACTION_TYPE;
|
28 | if (!~INTERACTION_TYPES.indexOf(subType)) {
|
29 | console.error(`provide a supported "type": ${INTERACTION_TYPES.join(', ')}`);
|
30 | process.exit(1);
|
31 | }
|
32 | }
|
33 |
|
34 | if (!name) {
|
35 | console.error('mandatory "name" not provided');
|
36 | process.exit(1);
|
37 | }
|
38 |
|
39 | create.newInteraction({
|
40 | name,
|
41 | remote: flags.remote,
|
42 | type: subType
|
43 | });
|
44 | };
|