agentsqripts
Version:
Comprehensive static code analysis toolkit for identifying technical debt, security vulnerabilities, performance issues, and code quality problems
94 lines (83 loc) • 2.98 kB
JavaScript
/**
* @file Command line argument parser for problem-scope CLI
* @description Handles parsing and validation of command-line arguments
*/
/**
* Parse command line arguments
* @param {Array<string>} args - Command line arguments
* @returns {Object} Parsed options and project path
*/
function parseCommandLineArgs(args) {
const options = {
analysis: ['all'],
outputFormat: 'summary',
severity: 'medium',
quick: false,
exportReport: null
};
let projectPath = '.';
for (let i = 0; i < args.length; i++) {
switch (args[i]) {
case '--analysis':
options.analysis = args[++i].split(',');
break;
case '--output-format':
options.outputFormat = args[++i];
break;
case '--severity':
options.severity = args[++i];
break;
case '--quick':
options.quick = true;
break;
case '--export-report':
options.exportReport = args[++i];
break;
default:
if (!args[i].startsWith('--')) {
projectPath = args[i];
}
}
}
return { options, projectPath };
}
/**
* Show usage information
*/
function showUsage() {
console.log(`
Usage: node problem-scope.js [OPTIONS] <project-path>
Comprehensive problem scope analysis for AI agents. Analyzes dependencies, complexity,
security, and technical debt to provide a complete picture of code issues.
OPTIONS:
--analysis <types> Comma-separated analysis types: dependencies,complexity,security,debt,srp,comments,variables,cleanup,refactoring,all (default: all)
--output-format <fmt> Output format: json, summary, detailed (default: summary)
--severity <level> Minimum issue severity: low, medium, high, critical (default: medium)
--quick Quick analysis mode (faster but less comprehensive)
--export-report <file> Export detailed report to file
--help Show this help message
ANALYSIS TYPES:
dependencies - Circular dependencies and file structure
complexity - Code complexity and maintainability
security - Security vulnerabilities and risks
debt - Technical debt indicators
srp - Single Responsibility Principle violations
comments - Documentation and comment quality
variables - Variable naming and usage patterns
cleanup - Code cleanup opportunities (barrel files, dead code)
refactoring - Export promotion and code organization opportunities
all - All analysis types (default)
EXAMPLES:
node problem-scope.js .
node problem-scope.js --analysis dependencies,security src/
node problem-scope.js --output-format json --export-report report.json .
node problem-scope.js --severity high --quick .
OUTPUT:
Provides comprehensive problem scope identification in the specified format,
perfect for AI agents to understand the full context of code issues.
`);
}
module.exports = {
parseCommandLineArgs,
showUsage
};