I use yargs for a complexe command line (with subcommands via commandDir). I'd like to use the .fail(fn) to send an email every time the given command failed. The .fail(fn) is correctly triggered but I'd like to be able to have access to the args given to the command. .fail(fn) only gives me access to msg, err, yargs.
require('yargs')
.commandDir('commands', {recurse: false})
.option('verbose', {
alias: 'v',
type: 'boolean',
description: 'Run with verbose logging',
default: false
})
.option('senderr', {
alias: 'se',
type: 'boolean',
description: 'Send error(s) via email',
default: true
})
.demandCommand()
.help()
.fail(function (msg, err, yargs) {
console.log(err);
process.exit(1);
})
.locale('fr')
.argv
Is it possible to access the argv.senderr value inside the fail function ? Thanks !