I am trying to use yargs library in my nestjs framework application, where few parameters i will be taking from command line args, if these parameters are not provided, I will be using the default one. Here is my cli.ts file.
import yargs from 'yargs';
const argv = yargs
.options('awsRegion', {
description: 'AWS Region (e.g. us-east-1, us-west-1)',
alias: 'aws-region',
type: 'string',
default: 'aws-east-1',
})
.options('avbLeaderId', {
description: 'leader id to be used for leader election',
alias: 'avb-leader-id',
type: 'string',
default: 'avb-leader-id',
})
.parseSync();
export default argv;
When I am trying to access the Property in constructor of a DB class -
export class DbService {
private client: DynamoDB;
constructor() {
this.client = new DynamoDB({
region: argv.awsRegion,
});
}
I am getting following errors when i run using npm run start:dev --aws-region=us-west-1 -
.options('awsRegion', {
^
TypeError: yargs_1.default.options is not a function
I have tried to go through documentation, but i am not gettting it.
Any help will be much appreciated.