I am looking to get the automatically generated help that results from yargs.getHelp() and instead I am getting an error that the function is not defined. Here is the sample code:
const yargs = require('yargs/yargs');
const { hideBin } = require('yargs/helpers');
const { parsed, boolean } = require("yargs");
async function parseArgs(){
let parsedArgs = yargs(hideBin(process.argv))
.option("trend-file", {
alias: "t",
description: "The full filename of the trendfile.",
type: "string",
})
.option("start-time", {
alias: "s",
description: "Start time for trend.",
type: "string",
})
.argv;
const test = await yargs.getHelp();
console.log(test);
}
parseArgs()
.catch((e)=>{console.log(e.message);});
Note: This is just an extraction of the larger code base. Commenting the line that calls yargs.getHelp() works fine. I feel like I am just doing this wrong. Anyone have a working example?
I am using yargs v17.2.1
Update--- I was able to get the help by passing all of the options to yargs() and then calling getHelp() like this:
let test = await yargs()
.option("trend-file", {
alias: "t",
description: "The full filename of the trendfile.",
type: "string",
})
.option("start-time", {
alias: "s",
description: "Start time for trend.",
type: "string",
})
.getHelp();
Is there a better way to do this without listing all the options twice?