Skip to content

Commit

Permalink
Refactored generate config command to modular functions
Browse files Browse the repository at this point in the history
  • Loading branch information
leelaprasadv committed Dec 2, 2024
1 parent 063d498 commit af8d7a9
Show file tree
Hide file tree
Showing 2 changed files with 357 additions and 392 deletions.
21 changes: 4 additions & 17 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,12 @@ const { GenerateConfigCommand } = require('./commands/generate-config.command');
const logger = require('./utils/logger');
const pkg = require('../package.json');

const banner = `
_____ _ ___ _
(_ _) ( )_ ( _'\\ ( )_
| | __ ___ | ,_)| (_) ) __ _ _ | ,_) ___
| | /'__'\\/',__)| | | _ <' /'__'\\ /'_' )| | /',__)
| |( ___/\\__, \\| |_ | (_) )( ___/( (_| || |_ \\__, \\
(_)'\\____)(____/'\\__)(____/''\\____)'\\__,_)'\\__)(____/
v${pkg.version}
Config Generation [BETA]
`

prog
.version(pkg.version)
.option('-l, --logLevel', 'Log Level', "INFO")


// Command to publish test results
prog.command('publish')
.option('-c, --config', 'path to config file')
.option('--api-key', 'api key')
Expand Down Expand Up @@ -54,21 +44,18 @@ prog.command('publish')
}
});

// Command to initialize and generate TestBeats Configuration file
prog.command('init')
.describe('Generate a TestBeats configuration file')
.example('init')
.action(async (opts) => {
console.log(banner)
try {
logger.setLevel(opts.logLevel);
logger.info(`🚧 Config generation is still in BETA mode, please report any issues at ${pkg.bugs.url}\n`);
const generate_command = new GenerateConfigCommand();
const generate_command = new GenerateConfigCommand(opts);
await generate_command.execute();
} catch (error) {
if (error.name === 'ExitPromptError') {
logger.info('😿 Configuration generation was canceled by the user.');
} else {
logger.debug(error.stack)
throw new Error(`❌ Error in generating configuration file: ${error.message}`)
}
process.exit(1);
Expand Down
Loading

0 comments on commit af8d7a9

Please sign in to comment.