-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
Hi there, sorry if this is a noob question but I am struggling to get the command option value in the following code:
const program = new Command()
const version = getVersion()
await Config.init()
program
.version(version)
.command('default')
.description('My CLI')
.action(async () => { defaultCommand() })
program
.command('import')
.description('Import data ')
.addArgument(new Argument('[account]', 'Account to import'))
.addArgument(new Argument('[transaction-type]', 'Type of transactions to import').choices(['deposits', 'withdrawals]))
.addOption(new Option('-f, --file <file>', 'File to import data from'))
.action((account, transactionType, options) => {
console.log(account, transactionType, options)
})Then when I execute the import command:
$ npm run dev import acc deposits --file blabla
> [email protected] dev /Users/nathanzylbersztejn/Documents/repos/greedy_cli
> DEV=true npx -r ts-node src/cli/cli.ts "import" "acc" "deposits" "/path/to/file"
acc deposits
{}
Metadata
Metadata
Assignees
Labels
No labels