-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathhelp.js
More file actions
46 lines (39 loc) · 986 Bytes
/
help.js
File metadata and controls
46 lines (39 loc) · 986 Bytes
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
/*
* `help.js`
*
* The purpose of this example is to demonstrate how the Help command can be included in a container.
*
* To run:
* $ node help.js help
* $ node help.js help coffee
*/
const {
Command,
Container,
Help
} = require('../index');
class BrewBeverage extends Command {
execute (params) {
console.log(`Let's prepare a cup of ${this.constructor.beverageName}.`);
if (params.extra.length > 0) {
console.log('Add the following extras:');
params.extra.forEach(extra => console.log(`- ${extra}`));
}
}
}
BrewBeverage.define({
switches: '{[extra:string[]]}'
});
class BrewCoffee extends BrewBeverage {}
BrewCoffee.beverageName = 'coffee';
class BrewTea extends BrewBeverage {}
BrewTea.beverageName = 'tea';
class Coffeehouse extends Container {}
Coffeehouse.define({
commands: {
coffee: BrewCoffee,
tea: BrewTea,
help: Help
}
});
new Coffeehouse().run();