31 lines
767 B
TypeScript
31 lines
767 B
TypeScript
import { parseArgs } from "node:util";
|
|
import { install } from "./install.js";
|
|
import { update } from "./update.js";
|
|
import { remove } from "./remove.js";
|
|
|
|
const { positionals, values } = parseArgs({
|
|
allowPositionals: true,
|
|
options: { yes: { type: "boolean", short: "y", default: false } },
|
|
});
|
|
const [command] = positionals;
|
|
|
|
try {
|
|
switch (command) {
|
|
case "install":
|
|
await install({ yes: values.yes });
|
|
break;
|
|
case "update":
|
|
await update({ yes: values.yes });
|
|
break;
|
|
case "remove":
|
|
await remove();
|
|
break;
|
|
default:
|
|
console.error("Usage: dotfiles <install|update|remove> [-y|--yes]");
|
|
process.exit(1);
|
|
}
|
|
} catch (err) {
|
|
console.error(`\nError: ${(err as Error).message}`);
|
|
process.exit(1);
|
|
}
|