diff --git a/cmd/fml/fml.go b/cmd/fml/fml.go index b120c9b..f15b522 100644 --- a/cmd/fml/fml.go +++ b/cmd/fml/fml.go @@ -14,9 +14,9 @@ import ( ) type config struct { - modsdir, infile, outfile string - mods modlist.Modlist - clobber, addmissing bool + modsdir, infile, outfile string + mods modlist.Modlist + clobber, addmissing, missingstate bool } var cfg config @@ -79,6 +79,12 @@ func main() { Required: false, Usage: "don't automatically add mods missing from infile", }, + &cli.BoolFlag{ + Name: "enable-missing", + Aliases: []string{"e"}, + Required: false, + Usage: "Missing mods are added in enabled state", + }, }, Before: func(ctx *cli.Context) error { // Setup logger @@ -93,6 +99,7 @@ func main() { // Bool flags cfg.clobber = ctx.Bool("clobber") cfg.addmissing = !ctx.Bool("no-add-missing") + cfg.missingstate = ctx.Bool("enable-missing") // Deal with in/out file var in = ctx.String("infile") @@ -124,7 +131,7 @@ func main() { } if cfg.addmissing { - err = modlist.AddModsNotInList(cfg.modsdir, &cfg.mods) + err = modlist.AddModsNotInList(cfg.modsdir, &cfg.mods, cfg.missingstate) if err != nil { return err } diff --git a/internal/modlist/modlist.go b/internal/modlist/modlist.go index 78fde4d..22e55df 100644 --- a/internal/modlist/modlist.go +++ b/internal/modlist/modlist.go @@ -152,7 +152,7 @@ func ReadFromFile(filename string) (Modlist, error) { } // AddModsNotInList finds mod archives in the mod folder that aren't in the modlist, and adds them. -func AddModsNotInList(modsdir string, mods *Modlist) error { +func AddModsNotInList(modsdir string, mods *Modlist, state bool) error { r := regexp.MustCompile(fileRegex) files, err := os.ReadDir(modsdir) @@ -167,10 +167,10 @@ func AddModsNotInList(modsdir string, mods *Modlist) error { version := groups[0][2] if !mods.HasMod(name) { - log.Info("Found %s not in modlist, adding v%s in disabled state.", name, version) + log.Infof("Found %s not in modlist, adding v%s in disabled state.", name, version) mods.Mods = append(mods.Mods, Mod{ Name: name, - Enabled: false, + Enabled: state, }) } }