diff --git a/src/commands/essential_command.ts b/src/commands/essential_command.ts index 4450a3b..4a7456f 100644 --- a/src/commands/essential_command.ts +++ b/src/commands/essential_command.ts @@ -6,12 +6,12 @@ import Mods from "../mods/mods.js"; export default class EssentialCommand implements Subcommand { registerCommand(program: Command): void { program.command("essential") - .description("Marks mods as essential") - .argument("", "The mods to mark as essential (as names or ids)") + .description("Toggles the mods essential statuses") + .argument("", "The mods to toggle the essential status of (as names or ids)") .action((mods) => { ModManager.execute(() => { for (let mod of mods) { - Mods.markEssential(mod) + Mods.toggleEssential(mod) } }) }) diff --git a/src/mods/mods.ts b/src/mods/mods.ts index 4bcedb2..1223553 100644 --- a/src/mods/mods.ts +++ b/src/mods/mods.ts @@ -119,7 +119,7 @@ export default class Mods { return mod1.id === mod2.id; } - static markEssential(mod: string) { + static toggleEssential(mod: string) { const modToMark = this.findMod(mod); if (modToMark != undefined) { @@ -127,13 +127,16 @@ export default class Mods { // Remove mod from list mods = mods.filter(item => !Mods.areModsEqual(item, modToMark)); - // Mark is as essential, and read it - modToMark.essential = true; + // Toggle essnetial status, and write back to file + modToMark.essential = !modToMark.essential; mods.push(modToMark) - this.writeFile(mods); - PrintUtils.success(`Marked ${modToMark.name} as essential`) + if (modToMark.essential) { + PrintUtils.success(`Marked ${modToMark.name} as essential`) + } else { + PrintUtils.success(`Marked ${modToMark.name} as inessential`) + } } else { PrintUtils.error(`${mod} not found.`) }