UNPKG

lambee

Version:

A tool to help developer work with AWS Lambda.

24 lines (18 loc) 912 B
const open = require('open') /** * Registers this CLI action with Commander. * * @param {*} program An instance of Commander CLI library */ function registerAction(program) { program .command('fnopen <functionName>') .description('Opens a Lambda function in the AWS console.') .option('--region <region>', 'The AWS region. You can set this using environment variable AWS_DEFAULT_REGION.') .action((functionName, cmdObj) => { const region = cmdObj.region || process.env.AWS_DEFAULT_REGION if (!region) return console.error('AWS region not set. Use --region option or AWS_DEFAULT_REGION environment variable.') open(`https://${region}.console.aws.amazon.com/lambda/home?region=${region}#/functions/${functionName}?tab=graph`).catch(console.error) }) } module.exports = { registerAction }