z_mirror/fmm
git clone https://git.raiguard.me/z_mirror/fmm
8b551e4
predep-parsing
1package main 2 3import ( 4"fmt" 5"os" 6 7"github.com/adrg/xdg" 8) 9 10var ( 11apiKey string = "" 12configPath string = "./fmm.ini" 13downloadToken string = "" 14downloadUsername string = "" 15modsDir string = "." 16) 17 18const usageStr string = `usage: fmm <operation> [args...] 19operations: 20disable [mods...] Disable the given mods, or all mods if none are given 21enable [mods...] Enable the given mods 22help Show usage information 23install [mods...] Install (if needed) and enable the given mods from the mod portal 24sync [files...] Sync active mods with the given log file 25upload [files...] Upload the given mod zip files to the mod portal` 26 27func printUsage (msg ... any ) { 28errorln (usageStr ) 29os .Exit (1 ) 30} 31 32// CONTROL FLOW: 33// - Read config file 34// - Parse input list into list of ModIdent, taking from: 35// - User representation ("EditorExtensions") 36// - Save file 37// - Log file 38// - Mod-list.json 39// - Mod sets? 40// - Add missing dependencies, fetching from portal if needed 41// - Keep note of which are present and which need to be downloaded 42// - Check for incompatibilities and circular dependencies in list and currently enabled mods 43// - Confirm actions with user? 44// - Execute each enable or download action 45 46func main () { 47xdgConfigPath ,err := xdg .ConfigFile ("fmm/fmm.ini" ) 48if err == nil { 49configPath = xdgConfigPath 50 } 51if err := parseConfig (configPath );err != nil { 52abort ("could not parse config file:" ,err ) 53 } 54 55if _ ,err := os .Stat ("mod-list.json" );err == nil { 56fmt .Println ("Using current directory" ) 57modsDir = "." 58 } 59 60args := os .Args [1 :] 61if len (args )== 0 { 62abort ("no operation was specified" ) 63 } 64 65mods := parseMods (args ,true ) 66for _ ,mod := range mods { 67fmt .Println (mod .toString ()) 68 } 69 70// var task func([]string) 71// switch args[0] { 72// case "disable", "d": 73// task = disable 74// case "enable", "e": 75// task = enable 76// case "help", "h": 77// printUsage() 78// case "install", "i": 79// task = install 80// case "sync", "s": 81// task = sync 82// case "upload", "ul": 83// task = upload 84// default: 85// abort(fmt.Sprintf("unrecognized operation %s", args[0])) 86// } 87// task(args[1:]) 88}