javascript

[Javascript][yargs] show/print help

kimxavi 2020. 2. 21. 09:42
반응형

개요

yargs 에서 임의로 help를 출력해주고 싶을 때 사용한다

코드

const yargs = require('yargs');

const argv = yargs
    .command('lyr', 'Tells whether an year is leap year or not', {
        year: {
            description: 'the year to check for',
            alias: 'y',
            type: 'number',
        }
    })
    .option('time', {
        alias: 't',
        description: 'Tell the present Time',
        type: 'boolean',
    })
    .help()
    .alias('help', 'h')
    .argv;
    
yargs.showHelp();
반응형