forked from EpiphanySoft/switchit
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinteractive.js
More file actions
31 lines (29 loc) · 703 Bytes
/
interactive.js
File metadata and controls
31 lines (29 loc) · 703 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
/*
* `interactive.js`
*
* The purpose of this example is to demonstrate the interactive capabilities of `switchit`.
*
* To run:
* $ node interactive.js
*/
const Command = require('../').Command;
class SayHi extends Command {
execute (params) {
console.log(`Hi, ${params.name}!`);
}
}
SayHi.define({
parameters: 'name',
interactive: true,
// Optionally add some help texts to improve the UI
// more info at docs/Readme.md#built-in-help-command
help: {
'': 'This is a command that says hi!',
'name': 'Your name'
}
});
new SayHi().run().then(() => {
console.log("Success!");
},(e) => {
console.error(`Oh no! ${e.message}`);
});