-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add pinning mods functionality - closes #23
- Loading branch information
1 parent
42d7ee8
commit d255b5f
Showing
6 changed files
with
83 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import asyncdispatch, asyncfutures, options, os | ||
import common | ||
import ../api/cfcore, ../api/cfclient | ||
import ../modpack/install, ../modpack/manifest | ||
import ../term/log, ../term/prompt | ||
import ../util/flow | ||
|
||
proc paxPin*(name: string): void = | ||
## pin/unpin an installed mod | ||
requirePaxProject() | ||
|
||
echoDebug "Loading data from manifest.." | ||
var manifest = readManifestFromDisk() | ||
|
||
echoDebug "Loading mods.." | ||
let mcMods = waitFor(fetchAddonsByQuery(name)) | ||
|
||
echoDebug "Searching for mod.." | ||
let mcModOption = manifest.promptAddonChoice(mcMods, selectInstalled = true) | ||
if mcModOption.isNone: | ||
echoError "No installed mods found for your search." | ||
quit(1) | ||
let mcMod = mcModOption.get() | ||
|
||
echo "" | ||
echoRoot "SELECTED MOD".dim | ||
echoAddon(mcMod) | ||
echo "" | ||
|
||
let manifestFile = manifest.getFile(mcMod.projectId) | ||
|
||
if manifestFile.metadata.pinned: | ||
returnIfNot promptYN("Unpin this mod?", default = true) | ||
echoInfo "Unpinning ", mcMod.name.fgCyan, ".." | ||
else: | ||
returnIfNot promptYN("Pin this mod to the current version?", default = true) | ||
echoInfo "Removing ", mcMod.name.fgCyan, ".." | ||
|
||
manifestFile.metadata.pinned = not manifestFile.metadata.pinned | ||
updateAddon(manifest, manifestFile) | ||
|
||
echoDebug "Writing to manifest..." | ||
manifest.writeToDisk() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters