dev: interactive prompt for file limit

This commit is contained in:
KernelDeimos 2024-12-02 11:09:50 -05:00
parent ac44aaf393
commit aadb261b29

View File

@ -524,10 +524,11 @@ const main = async () => {
excludes: FILE_EXCLUDES, excludes: FILE_EXCLUDES,
}, rootpath); }, rootpath);
let i = 0; let i = 0, limit = undefined;
for await ( const value of walk_iter ) { for await ( const value of walk_iter ) {
if ( limit !== undefined && i >= limit ) break;
i++; i++;
if ( i == 12 ) process.exit(0);
// Exit after processing 12 files // Exit after processing 12 files
if ( value.is_dir ) { if ( value.is_dir ) {
console.log('directory:', value.path); console.log('directory:', value.path);
@ -550,7 +551,7 @@ const main = async () => {
console.log('File was already commented by AI; skipping...'); console.log('File was already commented by AI; skipping...');
continue; continue;
} }
} } else metadata = {};
let refs = null; let refs = null;
// Check if there are any references in the metadata // Check if there are any references in the metadata
@ -589,16 +590,18 @@ const main = async () => {
} }
} }
const action = await enq.prompt({ const action = limit === undefined ? await enq.prompt({
type: 'select', type: 'select',
name: 'action', name: 'action',
message: 'Select action:', message: 'Select action:',
choices: [ choices: [
'generate', 'generate',
'skip', 'skip',
'all',
'limit',
'exit', 'exit',
] ]
}) }) : 'generate';
// const action = 'generate'; // const action = 'generate';
// Check if user wants to exit the program // Check if user wants to exit the program
@ -611,6 +614,26 @@ const main = async () => {
continue; continue;
} }
if ( action.action === 'limit' ) {
limit = await enq.prompt({
type: 'input',
name: 'limit',
message: 'Enter limit:'
});
i = 1;
limit = Number(limit.limit);
}
if ( action.action === 'all' ) {
limit = await enq.prompt({
type: 'input',
name: 'limit',
message: 'Enter limit:'
});
i = 1;
limit = Number(limit.limit);
}
const { definitions } = js_processor.process(lines); const { definitions } = js_processor.process(lines);
const key_places = []; const key_places = [];
key_places.push({ key_places.push({