Update index in import/add, improve index funcs

This commit is contained in:
comp500
2019-06-14 18:07:58 +01:00
parent 310078b1fb
commit 8eeb509565
4 changed files with 112 additions and 65 deletions

View File

@@ -43,6 +43,15 @@ type twitchPackMeta struct {
}
func cmdImport(flags core.Flags, file string) error {
pack, err := core.LoadPack(flags)
if err != nil {
return cli.NewExitError(err, 1)
}
index, err := pack.LoadIndex()
if err != nil {
return cli.NewExitError(err, 1)
}
var packMeta twitchPackMeta
// TODO: is this relative to something?
f, err := os.Open(file)
@@ -83,14 +92,19 @@ func cmdImport(flags core.Flags, file string) error {
continue
}
fmt.Printf("Imported \"%s\" successfully!\n", modInfoValue.Name)
fmt.Printf("Imported mod \"%s\" successfully!\n", modInfoValue.Name)
err = createModFile(flags, modInfoValue, modFileInfo(v.File))
err = createModFile(flags, modInfoValue, modFileInfo(v.File), &index)
if err != nil {
return cli.NewExitError(err, 1)
}
}
err = index.Write()
if err != nil {
return cli.NewExitError(err, 1)
}
// TODO: import existing files (config etc.)
return nil