mirror of
https://git.bits.team/Bits/mod-manager.git
synced 2024-11-21 21:48: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 {
|
export default class EssentialCommand implements Subcommand {
|
||||||
registerCommand(program: Command): void {
|
registerCommand(program: Command): void {
|
||||||
program.command("essential")
|
program.command("essential")
|
||||||
.description("Marks mods as essential")
|
.description("Toggles the mods essential statuses")
|
||||||
.argument("<mods...>", "The mods to mark as essential (as names or ids)")
|
.argument("<mods...>", "The mods to toggle the essential status of (as names or ids)")
|
||||||
.action((mods) => {
|
.action((mods) => {
|
||||||
ModManager.execute(() => {
|
ModManager.execute(() => {
|
||||||
for (let mod of mods) {
|
for (let mod of mods) {
|
||||||
Mods.markEssential(mod)
|
Mods.toggleEssential(mod)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -119,7 +119,7 @@ export default class Mods {
|
|||||||
return mod1.id === mod2.id;
|
return mod1.id === mod2.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
static markEssential(mod: string) {
|
static toggleEssential(mod: string) {
|
||||||
const modToMark = this.findMod(mod);
|
const modToMark = this.findMod(mod);
|
||||||
|
|
||||||
if (modToMark != undefined) {
|
if (modToMark != undefined) {
|
||||||
@ -127,13 +127,16 @@ export default class Mods {
|
|||||||
// Remove mod from list
|
// Remove mod from list
|
||||||
mods = mods.filter(item => !Mods.areModsEqual(item, modToMark));
|
mods = mods.filter(item => !Mods.areModsEqual(item, modToMark));
|
||||||
|
|
||||||
// Mark is as essential, and read it
|
// Toggle essnetial status, and write back to file
|
||||||
modToMark.essential = true;
|
modToMark.essential = !modToMark.essential;
|
||||||
mods.push(modToMark)
|
mods.push(modToMark)
|
||||||
|
|
||||||
this.writeFile(mods);
|
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 {
|
} else {
|
||||||
PrintUtils.error(`${mod} not found.`)
|
PrintUtils.error(`${mod} not found.`)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user