(argv)
| 17 | } = require('../core/map'); |
| 18 | |
| 19 | function parseArgs(argv) { |
| 20 | const opts = { |
| 21 | mode: 'generate', |
| 22 | root: process.cwd(), |
| 23 | output: null, |
| 24 | force: false, |
| 25 | query: '', |
| 26 | maxFiles: 20, |
| 27 | json: false, |
| 28 | }; |
| 29 | |
| 30 | let i = 0; |
| 31 | while (i < argv.length) { |
| 32 | const arg = argv[i]; |
| 33 | if (arg === '--generate') opts.mode = 'generate'; |
| 34 | else if (arg === '--query') { |
| 35 | opts.mode = 'query'; |
| 36 | opts.query = argv[++i] || ''; |
| 37 | } else if (arg === '--slice') { |
| 38 | opts.mode = 'slice'; |
| 39 | opts.query = argv[++i] || ''; |
| 40 | if (opts.maxFiles === 20) opts.maxFiles = 15; |
| 41 | } else if (arg === '--stats') opts.mode = 'stats'; |
| 42 | else if (arg === '--stale') opts.mode = 'stale'; |
| 43 | else if (arg === '--root') opts.root = path.resolve(argv[++i] || '.'); |
| 44 | else if (arg === '--output') opts.output = path.resolve(argv[++i] || ''); |
| 45 | else if (arg === '--force') opts.force = true; |
| 46 | else if (arg === '--json') opts.json = true; |
| 47 | else if (arg === '--max-files') opts.maxFiles = parseInt(argv[++i], 10) || opts.maxFiles; |
| 48 | else if (!arg.startsWith('--')) { |
| 49 | if (!opts.query) opts.query = arg; |
| 50 | } |
| 51 | i++; |
| 52 | } |
| 53 | |
| 54 | if (!opts.output) opts.output = defaultOutputPath(opts.root); |
| 55 | return opts; |
| 56 | } |
| 57 | |
| 58 | function printStats(stats) { |
| 59 | console.log('\nCodebase Index Statistics\n' + '='.repeat(40)); |
no test coverage detected