Last active
January 30, 2018 04:16
-
-
Save pariola/c7de8c64e7d5a973760c5772355c23cd to your computer and use it in GitHub Desktop.
New HelloCLI js
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
#! /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