-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
46 lines (41 loc) · 945 Bytes
/
cli.js
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
var compilateur = require('./compilateurLogo.js');
var fs = require('fs');
var content = require('./template.js');
var prompt = require('prompt');
var outputFile = process.argv[2];
var userInput = [];
var schema = {
properties : {
mot: {
pattern: /^[a-z]/,
message: "must be 'av' or 'td'",
required: true
},
pas: {
pattern: /^[1-9]/,
message: "must be a number between 1 and 200 ",
required: true
},
}
};
var i = 0;
function nextPrompt(){
prompt.get(schema, function (err, result){
userInput.push(result.mot+' '+ result.pas);
i= i+1;
if (i<2){
nextPrompt();
} else {
var instructions = compilateur.CompilateurLogo(userInput);
fs.writeFile(outputFile, content(instructions), function(err){
if (err) throw err;
console.log('File written');
});
};
});
};
prompt.start();
prompt.get(schema, function (err, result){
userInput.push(result.mot+' '+ result.pas);
nextPrompt();
});