Improve optional stuff, add preserve flag

This commit is contained in:
comp500 2019-06-16 23:09:40 +01:00
parent e3bf7afe33
commit dc9fd4689f
No known key found for this signature in database
GPG Key ID: 214C822FFEC586B5
2 changed files with 9 additions and 3 deletions

View File

@ -26,12 +26,13 @@ type Index struct {
// IndexFile is a file in the index // IndexFile is a file in the index
type IndexFile struct { type IndexFile struct {
// Files are stored in relative forward-slash format to the index file // Files are stored in forward-slash format relative to the index file
File string `toml:"file"` File string `toml:"file"`
Hash string `toml:"hash"` Hash string `toml:"hash"`
HashFormat string `toml:"hash-format,omitempty"` HashFormat string `toml:"hash-format,omitempty"`
Alias string `toml:"alias,omitempty"` Alias string `toml:"alias,omitempty"`
MetaFile bool `toml:"metafile,omitempty"` // True when it is a .toml metadata file MetaFile bool `toml:"metafile,omitempty"` // True when it is a .toml metadata file
Preserve bool `toml:"preserve,omitempty"` // Don't overwrite the file when updating
fileExistsTemp bool fileExistsTemp bool
} }

View File

@ -16,11 +16,16 @@ type Mod struct {
Name string `toml:"name"` Name string `toml:"name"`
FileName string `toml:"filename"` FileName string `toml:"filename"`
Side string `toml:"side,omitempty"` Side string `toml:"side,omitempty"`
Optional bool `toml:"optional,omitempty"`
Download ModDownload `toml:"download"` Download ModDownload `toml:"download"`
// Update is a map of map of stuff, so you can store arbitrary values on string keys to define updating // Update is a map of map of stuff, so you can store arbitrary values on string keys to define updating
Update map[string]map[string]interface{} `toml:"update"` Update map[string]map[string]interface{} `toml:"update"`
updateData map[string]interface{} updateData map[string]interface{}
Option *struct {
Optional bool `toml:"optional"`
Description string `toml:"description,omitempty"`
Default bool `toml:"default,omitempty"`
} `toml:"option,omitempty"`
} }
// ModDownload specifies how to download the mod file // ModDownload specifies how to download the mod file
@ -95,4 +100,4 @@ func (m Mod) GetParsedUpdateData(updaterName string) (interface{}, bool) {
// GetFilePath is a clumsy hack that I made because Mod already stores it's path anyway // GetFilePath is a clumsy hack that I made because Mod already stores it's path anyway
func (m Mod) GetFilePath() string { func (m Mod) GetFilePath() string {
return m.metaFile return m.metaFile
} }