use fmt; use getopt; fn clean(config: config, args: []str) void = { const help: []getopt::help = [ "remove the given mods from the mods directory", ('a', "remove all non-symlink mods"), "[mods...]" ]; let cmd = getopt::parse(args, help...); if (len(cmd.args) == 0) { abort_usage(args[0], help, "no argument was provided"); }; abort("clean subcommand is not yet implemented"); }; fn disable(config: config, args: []str) void = { const help: []getopt::help = [ "disable the given mods, or all mods if none are given", "[mods...]" ]; let cmd = getopt::parse(args, help...); defer getopt::finish(&cmd); // TODO: Error handling let dir = dir_load(config.mods_dir)!; defer dir_free(&dir); if (len(cmd.args) == 0) { dir_disable_all(&dir); } else { const mods = modident_parseall(&cmd.args, &config); defer modident_free_all(mods); dir_update_enabled(&dir, mods, false); }; dir_save(&dir); }; fn enable(config: config, args: []str) void = { const help: []getopt::help = [ "enable the given mods", "[mods...]" ]; let cmd = getopt::parse(args, help...); defer getopt::finish(&cmd); if (len(cmd.args) == 0) { abort_usage(args[0], help, "no mods were provided"); }; let dir = match (dir_load(config.mods_dir)) { case let dir: dir => yield dir; case let err: dir_error => fmt::fatalf("Could not open mods directory at {}: {}", config.mods_dir, dir_strerror(err)); }; defer dir_free(&dir); const mods = modident_parseall(&cmd.args, &config); defer modident_free_all(mods); dir_update_enabled(&dir, mods, true); dir_save(&dir); }; fn install(config: config, args: []str) void = { const help: []getopt::help = [ "install mods from the mod portal", ('d', "only download mods - do not change mod states"), ('f', "force install mods even if already present"), "[mods...]" ]; let cmd = getopt::parse(args, help...); if (len(cmd.args) == 0) { abort_usage(args[0], help, "no mods were provided"); }; abort("install subcommand is not yet implemented"); }; fn query(config: config, args: []str) void = { const help: []getopt::help = [ "search the local mods folder", ('d', "list dependencies"), "" ]; let cmd = getopt::parse(args, help...); if (len(cmd.args) == 0) { abort_usage(args[0], help, "no query was provided"); }; abort("query subcommand is not yet implemented"); }; fn sync(config: config, args: []str) void = { const help: []getopt::help = [ "sync the state of the mods folder, installing mods if needed", ('f', "force download mods even if already present"), ('s', "do not sync mod startup settings"), "" ]; let cmd = getopt::parse(args, help...); if (len(cmd.args) == 0) { abort_usage(args[0], help, "no arguments were provided"); }; fmt::errorln("Note: sync subcommand onlys supports [mods...] right now")!; let dir = match (dir_load(config.mods_dir)) { case let dir: dir => yield dir; case let err: dir_error => fmt::fatalf("Could not open mods directory at {}: {}", config.mods_dir, dir_strerror(err)); }; defer dir_free(&dir); dir_disable_all(&dir); const mods = modident_parseall(&cmd.args, &config); defer modident_free_all(mods); dir_update_enabled(&dir, mods, true); dir_save(&dir); }; fn publish(config: config, args: []str) void = { const help: []getopt::help = [ "publish a mod to the mod portal", ('d', "datestamp only"), ('u', "upload only - provide mod ZIP"), ('v', "increment version only"), ('z', "package only"), "" ]; let cmd = getopt::parse(args, help...); if (len(cmd.args) == 0) { abort_usage(args[0], help, "no argument was provided"); }; abort("publish subcommand is not yet implemented"); };