Last active
May 19, 2018 15:04
-
-
Save ilko725/ab7f74f4b9cc3348a52c24f84a0b0daf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var program = require('commander'); | |
process.stdin.resume() | |
program | |
.version('0.1.1') | |
.option('-i, --input [name]', 'User input') | |
.parse(process.argv) | |
function dateHelloError(value) { | |
return new Promice(function(resolve, reject) { | |
switch (program.input) { | |
case 'date': | |
console.log(new Date()); | |
process.exit(2); | |
break; | |
case 'hello': | |
setTimeout(function() { | |
console.log("hello world"); | |
process.exit(2); | |
}, 1000); | |
break; | |
default: | |
console.log("Oh, g*vno! An error occured! Only 'date' or 'hello' appropriate."); | |
process.exit(2); | |
break; | |
}; | |
}) | |
} | |
dateHelloError(program.input); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment