Last active
October 5, 2017 15:38
-
-
Save whazzmaster/5e54c32e315738d29cb9db44ec9cd1ae to your computer and use it in GitHub Desktop.
ES6 Debugging: Application
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
import Cloud from '../cloud'; | |
import program from 'commander'; | |
let command, value; | |
const INC_CMD = 'increment'; | |
const DEC_CMD = 'decrement'; | |
program | |
.description('online incrementer: increment cloud-based counters') | |
.arguments('<cmd> [args]') | |
.action((cmd, args) => { | |
command = cmd; | |
value = parseInt(args, 10); | |
}) | |
.parse(process.argv); | |
let cloud = new Cloud(5); | |
console.log(`Starting at ${cloud.total}`); | |
switch (command) { | |
case INC_CMD: | |
cloud.increment(value); | |
console.log(`Total is now ${cloud.total}`); | |
break; | |
case DEC_CMD: | |
cloud.decrement(value); | |
console.log(`Total is now ${cloud.total}`); | |
break; | |
default: | |
console.error(`Unknown command: ${command}`); | |
process.exit(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment