All files / src/cli cliRunner.ts

89.47% Statements 17/19
80% Branches 4/5
100% Functions 1/1
89.47% Lines 17/19

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 291x         3x 3x   3x 3x 3x 3x 3x 3x   3x 1x   3x       1x 1x   1x 1x 1x  
#!/usr/bin/env node
 
import { Command } from 'commander';
import { run } from '../index.js';
 
export async function cliRunner() {
  const program = new Command();
 
  program
    .name('envilder')
    .description('A CLI tool to generate .env files from AWS SSM parameters')
    .version('0.1.0')
    .requiredOption('--map <path>', 'Path to the JSON file with environment variable mapping')
    .requiredOption('--envfile <path>', 'Path to the .env file to be generated');
 
  await program.parseAsync(process.argv);
  const options = program.opts();
 
  if (!options.map || !options.envfile) {
    throw new Error('Missing required arguments: --map and --envfile');
  }
 
  await run(options.map, options.envfile);
}
 
cliRunner().catch((error) => {
  console.error('🚨 Uh-oh! Looks like Mario fell into the wrong pipe! 🍄💥');
});