Documentation
¶
Overview ¶
Package fomod reads FOMOD installers: it parses fomod/ModuleConfig.xml, evaluates its flag, file and game-version conditions, and turns a set of choices into the file and folder copy operations the installer declares. It copies nothing and reads no disk beyond the fs.FS it is handed.
Index ¶
- Constants
- Variables
- func Find(fsys fs.FS) (string, error)
- func FlagsFrom(cfg Config, choices Choices, ctx EvalContext) map[string]string
- func Match(cfg Config, choices Choices, ctx EvalContext) bool
- func PluginType(p Plugin, flags map[string]string, ctx EvalContext) string
- func Unanswered(old, cfg Config, choices Choices, ctx EvalContext) bool
- type Choices
- type Composite
- type Conditional
- type Config
- type EvalContext
- type FileDep
- type FileIndex
- type FlagDep
- type FlagSet
- type GameDep
- type Group
- type Op
- type Plugin
- type Step
- type TypePattern
Constants ¶
const ( SelectExactlyOne = "SelectExactlyOne" SelectAtMostOne = "SelectAtMostOne" SelectAtLeastOne = "SelectAtLeastOne" SelectAll = "SelectAll" SelectAny = "SelectAny" )
const ( TypeRequired = "Required" TypeOptional = "Optional" TypeRecommended = "Recommended" TypeNotUsable = "NotUsable" TypeCouldBeUsable = "CouldBeUsable" )
const ( FileActive = "Active" FileInactive = "Inactive" FileMissing = "Missing" )
const ( OrderAscending = "Ascending" OrderDescending = "Descending" OrderExplicit = "Explicit" )
Order values of the installSteps, optionalFileGroups and plugins order attribute. Parse has already applied it to the lists it returns: Explicit keeps document order, the others sort by name.
Variables ¶
var ErrTooLarge = errors.New("fomod: config exceeds the read cap")
ErrTooLarge is returned by Open for a config larger than the read cap.
Functions ¶
func Find ¶
Find returns the slash path, relative to fsys, of fomod/ModuleConfig.xml, or "" when there is none. The fomod folder may sit at the root or one folder down; names are matched case-insensitively, preferring an exact spelling.
func FlagsFrom ¶
func FlagsFrom(cfg Config, choices Choices, ctx EvalContext) map[string]string
FlagsFrom returns condition flags set by the selected plugins, in step order.
func Match ¶
func Match(cfg Config, choices Choices, ctx EvalContext) bool
Match reports whether choices still name plugins that exist and satisfy each visible group's type.
func PluginType ¶
func PluginType(p Plugin, flags map[string]string, ctx EvalContext) string
PluginType is the effective type of a plugin under flags and file dependencies.
func Unanswered ¶
func Unanswered(old, cfg Config, choices Choices, ctx EvalContext) bool
Unanswered reports whether cfg shows a group the user picks from that neither old nor choices knew, so replaying choices made against old would decide it without asking.
Types ¶
type Composite ¶
type Composite struct {
Operator string
Files []FileDep
Flags []FlagDep
Games []GameDep
Nested []Composite
}
func (Composite) Eval ¶
func (c Composite) Eval(flags map[string]string, ctx EvalContext) bool
Eval reports whether the composite dependency holds.
func (*Composite) UnmarshalXML ¶
type Conditional ¶
type Config ¶
type Config struct {
ModuleName string
Required []Op
Steps []Step
StepOrder string
Conditionals []Conditional
}
Config is a parsed ModuleConfig.xml.
type EvalContext ¶
type EvalContext struct {
// Files answers fileDependency checks; nil reports every file FileMissing.
Files FileIndex
// GameVersion is the installed game's version, compared with each gameDependency minimum by go-semverish: a missing
// number counts as 0. "" means unknown, and any gameDependency is then unmet; a version either side that does not
// parse counts as met.
GameVersion string
}
EvalContext holds inputs for FOMOD dependency checks.
type FileDep ¶
func (*FileDep) UnmarshalXML ¶
type FileIndex ¶
FileIndex reports the state of a dependency file in the installed game: FileActive, FileInactive or FileMissing.
type FlagDep ¶
func (*FlagDep) UnmarshalXML ¶
type Op ¶
type Op struct {
Source string
// Destination is nil when the config names none, which installs at the source's own path; "" is the install
// folder itself.
Destination *string
Priority int
Folder bool
// Always and IfUsable install a plugin's file even when the plugin is not chosen, IfUsable only while the plugin's
// type is not NotUsable.
Always, IfUsable bool
}
Op is one file or folder the installer copies from the archive into the install root.
type Step ¶
type Step struct {
Name string
Visible Composite
Groups []Group
// GroupOrder is the order attribute of this step's optionalFileGroups.
GroupOrder string
}
func VisibleSteps ¶
func VisibleSteps(cfg Config, flags map[string]string, ctx EvalContext) []Step
VisibleSteps are install steps whose visible condition holds.