Skip to content

Commit 78b47c5

Browse files
committed
feat: prompt user if mod ids could not be parsed (fixes #7)
1 parent 7c289fe commit 78b47c5

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

interactive/mods-add.go

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,34 @@ func addMod(id string, config *ini.ServerConfig) (bool, error) {
6969

7070
parsed := item.Parse()
7171
if len(parsed.Mods) == 0 {
72-
return false, fmt.Errorf("parsed item has no mods")
72+
fmt.Println(util.Warning, "Could not parse Mod ID(s) from item:", util.Quote(item.Title))
73+
if Confirm("Would you like to enter the Mod ID manually?", true) {
74+
for {
75+
var mod string
76+
err := survey.AskOne(&survey.Input{
77+
Message: "Mod name:",
78+
Help: "Enter a single Mod ID, or leave blank to finish.",
79+
}, &mod)
80+
81+
if err != nil {
82+
return false, err
83+
}
84+
85+
if mod == "" {
86+
break
87+
}
88+
89+
parsed.Mods = append(parsed.Mods, mod)
90+
fmt.Println(util.Info, "Manually added mod:", mod)
91+
92+
if !Confirm("Add another Mod ID?", true) {
93+
break
94+
}
95+
}
96+
} else {
97+
return false, fmt.Errorf("parsed item has no mods")
98+
}
99+
73100
}
74101

75102
modList := getFixedArray(config, util.CfgKeyMods)

0 commit comments

Comments
 (0)