nested-properties-prompt.js
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
32
33
34
35
36
37
/*
* property-prompt.js: Example of using prompt with complex properties.
*
* (C) 2010, Nodejitsu Inc.
*
*/
var prompt = require('../lib/prompt');
var schema = {
properties: {
url: {
required: true,
format: 'url'
},
auth: {
properties: {
username: {
required: true
},
password: {
required: true,
hidden: true
}
}
}
}
};
prompt.start();
prompt.get(schema, function (err, result) {
console.log('Command-line input received:');
console.log(' url: ' + result.url);
console.log(' auth:username: ' + result.auth.username);
console.log(' auth:password: ' + result.auth.password);
});