"use strict";
const autostart = require("../lib/autostart");

const action = process.argv[2] || "status";

try {
  if (action === "install") {
    const cmd = autostart.install();
    console.log(`已加入開機自動啟動（${autostart.RUN_KEY}\\${autostart.VALUE_NAME}）`);
    console.log(cmd);
  } else if (action === "uninstall") {
    console.log(autostart.uninstall() ? "已移除開機自動啟動。" : "原本就沒有設定開機自動啟動。");
  } else {
    const installed = autostart.isInstalled();
    console.log(installed ? `開機自動啟動：已啟用\n${autostart.currentValue()}` : "開機自動啟動：未啟用");
  }
} catch (err) {
  console.error(err.message || err);
  process.exitCode = 1;
}
