OSDN Git Service

2c0d6c18dbe4b1ebeea942ae31bedc754b8fbbc4
[eos/zephyr.git] / server / class / Eos.js
1     /**
2      * Eosコマンドをエミュレートするクラス 
3      * @constructor
4      * @returns {object}
5      * function execute(command, params) {
6      */
7 function Eos() {
8
9     /**
10      * include all Eos command's info.
11      * For seaching with O(n), the object key name is command name.
12      */
13     const commandReference = {
14         mrcImageInfo: { },
15         dcdFilePring: { }
16     };
17
18     return {
19         /**
20          * execute
21          *
22          * @param command
23          * @param params
24          * @returns {object}
25          */
26         execute: function(command, options) {
27             var result = {
28                 hasDone: false, // true | false
29                 comment: ''// string
30             };
31
32             /**
33              * Check of command name
34              */
35             if(typeof command !== 'string') {
36                 result.comment = 'command parameter need to be string';
37                 return result;
38             }
39
40             const hasCommand = Object.keys(commandReference).indexOf(command) > 0;
41             if(!hasCommand) {
42                 result.comment = 'command name is invalid';
43                 return result;
44             }
45             
46             /**
47              * Check of options
48              */
49
50
51             /**
52              * End of Success
53              */
54             result.hasDone = true;
55             result.comment = command + ' has done.';
56             return result;
57         }
58     }
59 }
60
61 module.exports = Eos;