nixos-configs/apps/update/src/app.ts

27 lines
657 B
TypeScript
Raw Normal View History

2024-07-20 20:30:43 -04:00
import { updateFirefoxAddons } from '././firefox.ts';
/* Parse Args */
const args = {} as Record<string, unknown>;
let lastFlag: string | null = null;
for (let i = 2; i < process.argv.length; ++i) {
const arg = process.argv[i];
if (arg.toString().startsWith('-')) {
lastFlag = arg.toString().replace(/^-{1,2}/, '');
args[lastFlag] = true;
}
else if (lastFlag) {
args[lastFlag] = arg;
lastFlag = null;
}
else {
console.error(`Could not parse args: ${arg.toString()}`);
}
}
/* Exec functions based on args */
if (args['f'] || args['firefox']) {
console.log(updateFirefoxAddons());
}