UNPKG

runtime-eol

Version:
59 lines (48 loc) 1.47 kB
const argParser = (arg) => { const parsed = { mode: 'check', tools: [] } for (let i = 0; i < arg.length; i++) { const current = arg[i]; if (current === '-h' || current === '--help') { parsed.mode = 'help'; continue; } if (current === '-s' || current === '--skip') { parsed.skipRemote = true; continue; } if (current === '-a' || current === '--add') { // Check if there are any arguments after the -a flag if (i + 1 >= arg.length || arg[i + 1].startsWith('-')) { console.error('Error: -a (--add) flag requires at least one argument'); parsed.mode = 'help'; break; } // Collect all subsequent arguments until the next flag while (i + 1 < arg.length && !arg[i + 1].startsWith('-')) { parsed.tools.push(arg[++i]); } } if (current === '-r' || current === '--recommend') { parsed.recommend = true; continue; } } return parsed; }; const printHelp = () => { console.log(`Available options: -s | --skip => Skip downloading from remote -a | --add [...] => Specify additional tools (e.g., -a python aws-lambda) -h | --help => Show this help message -r | --recommend => Checks higher version than minimum Examples: runtime-eol -a python aws-lambda runtime-eol -s `); }; module.exports = { argParser, printHelp, };