nodejs get param cli

// Step 1: Require the 'yargs' module for parsing command line arguments
const yargs = require('yargs');

// Step 2: Configure the expected command line arguments using yargs
const argv = yargs
  .option('param', {
    alias: 'p',
    description: 'Specify the parameter value',
    type: 'string',
    demandOption: true, // Make this option required
  })
  .argv;

// Step 3: Access the value of the specified parameter from the command line
const paramValue = argv.param;

// Step 4: Output the obtained parameter value
console.log('Parameter Value:', paramValue);

To use this script, run it from the command line with the desired parameter, like this:

node script.js --param=value

Replace 'script.js' with your script file name and 'value' with the actual value you want to pass as a parameter.