CLI Arguments with yargs (Node)
Declare commands and flags with yargs in a Node script.
Author:
chris
// Language: JavaScript
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
const argv = yargs(hideBin(process.argv))
.option('name', { type: 'string', demandOption: true })
.option('count', { type: 'number', default: 1 })
.option('verbose', { type: 'boolean', default: false })
.parse();
for (let i = 0; i < argv.count; i++) {
console.log(`Hello, ${argv.name}!`);
}