Skip to content

Instantly share code, notes, and snippets.

@ilko725
Last active May 19, 2018 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilko725/ab7f74f4b9cc3348a52c24f84a0b0daf to your computer and use it in GitHub Desktop.
Save ilko725/ab7f74f4b9cc3348a52c24f84a0b0daf to your computer and use it in GitHub Desktop.
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