Skip to content

Instantly share code, notes, and snippets.

@pariola
Last active January 30, 2018 04:16
Show Gist options
  • Save pariola/c7de8c64e7d5a973760c5772355c23cd to your computer and use it in GitHub Desktop.
Save pariola/c7de8c64e7d5a973760c5772355c23cd to your computer and use it in GitHub Desktop.
New HelloCLI js
#! /usr/bin/env node
const argv = require('yargs').argv;
// Parse command
if (argv._.length == 1) {
switch (argv._[0]) {
case 'greet':
greet(argv);
break;
default:
banner();
}
} else {
banner();
}
function greet(argv) {
if (argv.name) {
console.log(`Hello ${argv.name}! 😉`);
} else {
console.log('Please supply a name with --name');
}
}
function banner() {
console.log(`
Usage:
hello-cli greet [--name <Individual name>]
This will add a greet a user
`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment