-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcli.js
More file actions
63 lines (54 loc) · 1.87 KB
/
cli.js
File metadata and controls
63 lines (54 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const colors = require('colors/safe');
const createScene = require('./configs/cli/createScene');
const createObject = require('./configs/cli/createObj');
const updateIndex = require('./configs/cli/updateIndex');
/**
* Run using node (i.e. node cli help)
*/
const args = [];
process.argv.forEach(val => {
args.push(val);
});
if (args[2] === 'scene') {
createScene(args[3]);
}
if (args[2] === 'obj' || args[2] === 'object') {
createObject(args[3], args[4]);
}
if (args[2] === 'update') {
updateIndex('./src/scenes');
console.log(`${colors.bold(colors.blue(`scenes list updated.`))}`); // eslint-disable-line no-console
}
function updateSceneIndex() {
updateIndex('./src/scenes');
}
if (args[2] === 'update') {
if (args[3]) {
if (args[3] === 's') {
updateSceneIndex();
console.log(`${colors.bold(colors.blue(`scenes list updated.`))}`); // eslint-disable-line no-console
}
} else {
updateSceneIndex();
console.log(`${colors.bold(colors.blue(`All list updated.`))}`); // eslint-disable-line no-console
}
}
if (args[2] === 'help' || !args[2]) {
// eslint-disable-next-line
console.log(`${colors.bold(colors.bgRed('Here is the full list of available cmmand:'))}
scene: create game scene ${colors.bold(colors.grey('--->'))} ${colors.bold(
colors.yellow('node cli scene <scene-name>')
)}
obj || object: create game object ${colors.bold(colors.grey('--->'))} ${colors.bold(
colors.yellow('node cli obj <object-type> <object-name>')
)}
${colors.bold(colors.green('----------------------------------------------'))}
${colors.bold(colors.red('update'))} ${colors.bold(colors.grey('--->'))} ${colors.bold(
colors.yellow('node cli update')
)}
s - for updating game scene list ${colors.bold(colors.grey('--->'))} ${colors.bold(
colors.yellow('node cli update s')
)}
${colors.bold(`*for help - ${colors.cyan('node cli help')}`)}
`);
}