Started work on adding mod downloader

Read from mod-list.json in mod dir and download each mod in list.
This requires reading from factorio mod portal api, and extracting download url and calling it with username and api token.

new field in config.yml username and apitoken, is needed to download mod files from mod.factorio.com
This commit is contained in:
2026-04-30 12:06:49 -06:00
parent b2f485269b
commit 2548261d66
7 changed files with 151 additions and 7 deletions

21
cli.go
View File

@@ -6,7 +6,8 @@ import (
)
func cliToolMode() {
var c = readCfg(fmConfig)
var c = readCfg("config.yml")
modlist := string(c.Server.ServDir) + "/mods/mod-list.json"
if verifyConfig(c) {
if len(os.Args) > 1 {
switch os.Args[1] {
@@ -18,6 +19,22 @@ func cliToolMode() {
fmt.Printf("Start Server: %s start\nStop Server: %s stop\n", os.Args[0], os.Args[0])
fmt.Printf("Run backup\n\tFull backup: %s backup full", os.Args[0])
fmt.Printf("\n\tBackup saves: %s backup saves\n", os.Args[0])
case "mod":
if len(os.Args) > 2 {
switch os.Args[2] {
case "download":
if !findmodlist(modlist) {
fmt.Printf("FAILED TO FIND MOD LIST")
} else {
fmt.Printf("found %s\n", modlist)
downloadMods(modlist)
}
default:
fmt.Println("Invalid mod option: use 'update'")
}
} else {
fmt.Println("Missing mod option: use 'update'")
}
case "backup":
if len(os.Args) > 2 {
switch os.Args[2] {
@@ -35,7 +52,7 @@ func cliToolMode() {
fmt.Printf("Unknown command: %s. Use 'start', 'stop', or 'backup'.\n", os.Args[1])
}
} else {
fmt.Println("Use 'start', 'stop', or 'backup' command\nex. factoryman start\nTo configure edit 'conifg.yml'")
fmt.Println("Use 'start', 'stop', or 'backup' command\nex. factoryman start\nTo configure edit 'config.yml'")
}
}
}