z_mirror/fmm

git clone https://git.raiguard.me/z_mirror/fmm

Caleb HeuerFetch dependencies from portal8b551e4

predep-parsing
2.1 KiB88 linesraw
1package main
2
3import (
4	"fmt"
5	"os"
6
7	"github.com/adrg/xdg"
8)
9
10var (
11	apiKey           string = ""
12	configPath       string = "./fmm.ini"
13	downloadToken    string = ""
14	downloadUsername string = ""
15	modsDir          string = "."
16)
17
18const usageStr string = `usage: fmm <operation> [args...]
19operations:
20	disable [mods...]   Disable the given mods, or all mods if none are given
21	enable  [mods...]   Enable the given mods
22	help                Show usage information
23	install [mods...]   Install (if needed) and enable the given mods from the mod portal
24	sync    [files...]  Sync active mods with the given log file
25	upload  [files...]  Upload the given mod zip files to the mod portal`
26
27func printUsage(msg ...any) {
28	errorln(usageStr)
29	os.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() {
47	xdgConfigPath, err := xdg.ConfigFile("fmm/fmm.ini")
48	if err == nil {
49		configPath = xdgConfigPath
50	}
51	if err := parseConfig(configPath); err != nil {
52		abort("could not parse config file:", err)
53	}
54
55	if _, err := os.Stat("mod-list.json"); err == nil {
56		fmt.Println("Using current directory")
57		modsDir = "."
58	}
59
60	args := os.Args[1:]
61	if len(args) == 0 {
62		abort("no operation was specified")
63	}
64
65	mods := parseMods(args, true)
66	for _, mod := range mods {
67		fmt.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}