UNPKG

lambee

Version:

A tool to help developer work with AWS Lambda.

30 lines (24 loc) 1.53 kB
const listFunctions = require('./listFunctions') /** * Registers this CLI action with Commander. * * @param {*} program An instance of Commander CLI library */ function registerAction(program) { program .command('fnlist') .description('Prints a list of our Lambda functions.') .option('--profile <profile>', 'The AWS profile. You can set this using environment variable AWS_PROFILE.') .option('--region <region>', 'The AWS region. You can set this using environment variable AWS_DEFAULT_REGION.') .option('-c, --cache', 'Cache results locally. Makes repeated execution much quicker on slow networks. Will not pick up changes to the functions list though.') .option('-v, --verbose', 'Prints the full object returned by AWS SDK instead of just the function name.') .option('-d, --debug', 'Enable debug logging') .action((cmdObj) => { const profile = cmdObj.profile || process.env.AWS_PROFILE const region = cmdObj.region || process.env.AWS_DEFAULT_REGION if (!profile) return console.error('AWS profile not set. Use --profile option or AWS_PROFILE environment variable.') if (!region) return console.error('AWS region not set. Use --region option or AWS_DEFAULT_REGION environment variable.') listFunctions(cmdObj.cache, profile, region, cmdObj.verbose, cmdObj.debug).then(console.log).catch(console.log) }) } module.exports = { registerAction }