mirror of
https://git.bits.team/Bits/mod-manager.git
synced 2024-11-21 13:38:21 -05:00
Made essential command toggle essential status
This commit is contained in:
parent
e808a4f414
commit
935262ec0f
@ -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("<mods...>", "The mods to mark as essential (as names or ids)")
|
||||
.description("Toggles the mods essential statuses")
|
||||
.argument("<mods...>", "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)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -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.`)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user