Skip to content

Commit

Permalink
refresh disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ManApart committed Nov 3, 2023
1 parent a815e77 commit f12c6b2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 28 deletions.
4 changes: 2 additions & 2 deletions manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ purge |Purge all sym links | |purge - delete all symlinks and rename override fi
mod |Update a mod | |mod <mod index> id 123 - Update mod's id <br/>mod <mod index> file ~/Downloads/sleepy-time.zip - Delete mod's stage folder and restage from zip <br/>mod <mod index> name <new name> - renames a mod without changing file paths <br/>rename <mod index> <new name>
profile |Create and use local mod lists | |profile list <br/>profile save <name> - create a new profile <br/>profile save <index> - save to an existing profile <br/>profile view <index> <br/>profile load <index>
rename |Rename a mod |mv |mod <mod index> id 123 - Update mod's id <br/>mod <mod index> file ~/Downloads/sleepy-time.zip - Delete mod's stage folder and restage from zip <br/>mod <mod index> name <new name> - renames a mod without changing file paths <br/>rename <mod index> <new name>
refresh |Refresh mods by id | |refresh <mod index> <br/>refresh 1 2 4 <br/>refresh 1-3 <br/>refresh all - For all mods with ids, attempt to redownload (or grab the file from the downloads folder if it exists) and restage. <br/>refresh empty - Refresh any files without staged data <br/>refresh staged - Refresh only files that are staged <br/>refresh enabled - Refresh only files that are enabled <br/>If you're looking to upgrade to a new version, see update and upgrade
refresh |Refresh mods by id | |refresh <mod index> <br/>refresh 1 2 4 <br/>refresh 1-3 <br/>refresh all - For all mods with ids, attempt to redownload (or grab the file from the downloads folder if it exists) and restage. <br/>refresh empty - Refresh any files without staged data <br/>refresh staged - Refresh only files that are staged <br/>refresh enabled - Refresh only files that are enabled <br/>refresh disabled - Refresh only files that are NOT enabled <br/>If you're looking to upgrade to a new version, see update and upgrade
update |Check for newer versions | |update - fetches latest metadata for mods, including new versions and endorsement data <br/>update <mod index> <br/>update 1 2 4 <br/>update 1-3 <br/>Useful for checking for updates existing mods. To check add new mods, see fetch or add. <br/>To download updates, see upgrade
upgrade |Upgrade to newer versions | |upgrade <mod index> <br/>upgrade 1 2 4 <br/>upgrade 1-3 <br/>upgrade all - For all mods with newer versions, attempt to stage the latest version. <br/>If you want to check for new versions, see update <br/>If you're looking to just redownload or restage a file at the current version, see refresh
remove |Delete a mod |rm |remove <mod index> <br/>rm <mod index>
search |Search Mods |grep, awk |Search for mods and list them once <br/>To apply a filter to future lists, see filter <br/>search <search text> - search the given text (name or category) <br/>search 123 - show matching ids <br/>search enabled - show only enabled mods <br/>search disabled <br/>search staged <br/>search unstaged <br/>search missing - show missing ids
filter |Apply a filter to Mods | |filter mods that contain the given text (name or category) <br/>Changes persist across future ls until filter clear or filter all is called <br/>To do a one time search, see search <br/>filter <search text> - <br/>filter 123 - show matching ids <br/>filter enabled - show only enabled mods <br/>filter disabled <br/>filter staged <br/>filter unstaged <br/>filter missing - show missing ids
sort |Sort Mods | |sort the list in various ways. Add reverse to invert the sort <br/>sort name <br/>sort id <br/>sort enabled <br/>sort category <br/>sort order <br/>sort staged
validate |List issues with mods | |validate <br/>validate <mod index> <br/>validate 1 2 4 <br/>validate 1-3 <br/>validate staged <br/>validate enabled
validate |List issues with mods | |validate <br/>validate <mod index> <br/>validate 1 2 4 <br/>validate 1-3 <br/>validate staged <br/>validate enabled <br/>validate disabled
start |Launch Starfield |game |start - run the steam game
exit |Exit Program | |Exit the process

1 change: 1 addition & 0 deletions src/main/kotlin/commands/Profile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ private fun loadProfile(i: Int) {
val enabled = profile.ids.contains(mod.id) || profile.filePaths.contains(mod.filePath)
enableMod(enabled, modIndex)
}
save()
println("Loaded ${profile.name}")
}

Expand Down
26 changes: 10 additions & 16 deletions src/main/kotlin/commands/Refresh.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,17 @@ fun refreshHelp() = """
refresh empty - Refresh any files without staged data
refresh staged - Refresh only files that are staged
refresh enabled - Refresh only files that are enabled
refresh disabled - Refresh only files that are NOT enabled
If you're looking to upgrade to a new version, see update and upgrade
""".trimIndent()

fun refresh(args: List<String>) {
when {
args.isEmpty() -> println(refreshHelp())
args.first() == "empty" -> {
toolData.mods
.filter { !File(it.filePath).exists() }
.refreshMods()
}
args.first() == "staged" -> {
toolData.mods
.filter { File(it.filePath).exists() }
.refreshMods()
}
args.first() == "enabled" -> {
toolData.mods
.filter { it.enabled }
.refreshMods()
}
args.first() == "empty" -> refresh { !File(it.filePath).exists() }
args.first() == "staged" -> refresh { File(it.filePath).exists() }
args.first() == "enabled" -> refresh { it.enabled }
args.first() == "disabled" -> refresh { !it.enabled }
else -> {
args.getIndicesOrRange(toolData.mods.size)
.mapNotNull { toolData.byIndex(it) }
Expand All @@ -43,8 +33,12 @@ fun refresh(args: List<String>) {
}
}

private fun refresh(filter: (Mod) -> Boolean) {
toolData.mods.filter(filter).refreshMods()
}

private fun List<Mod>.refreshMods() {
also { println("Refreshing ${it.size} mods") }
also { println("Refreshing ${it.size} mods") }
.forEach { refreshMod(it) }
println("Done Refreshing")
}
24 changes: 14 additions & 10 deletions src/main/kotlin/commands/Validate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,27 @@ fun validateHelp() = """
validate 1-3
validate staged
validate enabled
validate disabled
""".trimIndent()

fun validateMods(args: List<String>) {
with(toolData.mods) {
when {
args.isEmpty() -> validate()
args.first() == "staged" -> filter { File(it.filePath).exists() }.validate()
args.first() == "enabled" -> filter { it.enabled }.validate()
else -> {
args.getIndicesOrRange(size)
.mapNotNull { toolData.byIndex(it) }
.validate()
}
when {
args.isEmpty() -> validate()
args.first() == "staged" -> validate { File(it.filePath).exists() }
args.first() == "enabled" -> validate { it.enabled }
args.first() == "disabled" -> validate { it.enabled }
else -> {
args.getIndicesOrRange(toolData.mods.size)
.mapNotNull { toolData.byIndex(it) }
.validate()
}
}
}

private fun validate(filter: (Mod) -> Boolean = {true}) {
toolData.mods.filter(filter).validate()
}

private fun List<Mod>.validate() {
println("Validating $size mods")
val errorMap = mutableMapOf<Int, Pair<Mod, MutableList<String>>>()
Expand Down

0 comments on commit f12c6b2

Please sign in to comment.