Skip to content

Instantly share code, notes, and snippets.

@whazzmaster
Last active October 5, 2017 15:38
Show Gist options
  • Save whazzmaster/5e54c32e315738d29cb9db44ec9cd1ae to your computer and use it in GitHub Desktop.
Save whazzmaster/5e54c32e315738d29cb9db44ec9cd1ae to your computer and use it in GitHub Desktop.
ES6 Debugging: Application
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