pury
Version:
🛡️ AI-powered security scanner with advanced threat detection, dual reporting system (detailed & summary), and comprehensive code analysis
64 lines (63 loc) • 2.38 kB
JavaScript
import { Command } from 'commander';
import { createScanCommand } from './commands/scan.js';
import { createCleanLogsCommand } from './commands/clean-logs.js';
import { createLocalizeCommand } from './commands/localize.js';
import { createEnvFormatCommand } from './commands/env-format.js';
import { createInitCommand } from './commands/init.js';
import { logger, LogLevel } from '../utils/logger.js';
const program = new Command();
program
.name('pury')
.description('AI-powered code security scanner - Detect malware, vulnerabilities, and optimize your codebase')
.version('0.1.1')
.option('-v, --verbose', 'Enable verbose logging')
.option('-q, --quiet', 'Suppress non-error output')
.option('--debug', 'Enable debug logging')
.hook('preAction', thisCommand => {
const options = thisCommand.opts();
if (options.debug) {
logger.setLevel(LogLevel.DEBUG);
}
else if (options.verbose) {
logger.setLevel(LogLevel.INFO);
}
else if (options.quiet) {
logger.setLevel(LogLevel.ERROR);
}
});
// Add commands
program.addCommand(createScanCommand());
program.addCommand(createCleanLogsCommand());
program.addCommand(createLocalizeCommand());
program.addCommand(createEnvFormatCommand());
program.addCommand(createInitCommand());
// Add global help examples
program.addHelpText('after', `
Examples:
$ pury scan ./src # Scan the src directory
$ pury scan . --format json # Scan current directory, output JSON
$ pury clean-logs ./src --apply # Remove console.log statements
$ pury localize ./src --apply # Translate non-English text
$ pury init # Create configuration file
For more information, visit: https://github.com/puryai/pury
`);
// Error handling
process.on('uncaughtException', error => {
logger.error(`Uncaught exception: ${error.message}`);
if (logger.getLevel() <= LogLevel.DEBUG) {
console.error(error.stack);
}
process.exit(1);
});
process.on('unhandledRejection', (reason, promise) => {
logger.error(`Unhandled rejection at: ${promise}, reason: ${reason}`);
process.exit(1);
});
// Parse command line arguments
program.parse();
// If no command is provided, show help
if (!process.argv.slice(2).length) {
program.outputHelp();
}
//# sourceMappingURL=cli.js.map