Documentation
¶
Overview ¶
Package cfgedit edits one setting of a BepInEx .cfg or a MelonLoader MelonPreferences.cfg and returns the new text, leaving every other byte as it was. The ini and msbuild subpackages do the same for INI and MSBuild files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoSetting = errors.New("no setting")
ErrNoSetting is wrapped by Set when the section has no such key. The wrapped text is "no setting <key> in [<section>]".
Functions ¶
This section is empty.
Types ¶
type BepInEx ¶
type BepInEx struct {
// contains filtered or unexported fields
}
BepInEx is a parsed BepInEx .cfg. It keeps the original lines, so a Set changes only the edited line.
func ParseBepInEx ¶
ParseBepInEx reads a BepInEx .cfg. It never fails: a line it does not understand is skipped.
type Entry ¶
type Entry struct {
Section, Key string
Type Type
// Value is the BepInEx value as the file holds it, escapes included; a Melon string is unquoted and unescaped.
Value string
Default string // BepInEx only.
HasDefault bool
Description string
Min, Max *float64 // An acceptable range the file states.
Values []string // The acceptable values of an enum.
Flags bool // An enum whose values combine with commas.
}
Entry is one setting, in file order.
type Melon ¶
type Melon struct {
// contains filtered or unexported fields
}
Melon is a parsed MelonPreferences.cfg. It keeps the original lines, so a Set changes only the edited value.
func ParseMelon ¶
ParseMelon reads a MelonPreferences.cfg. It never fails: a line it does not understand is skipped.
type Problem ¶
type Problem string
Problem is why a value was refused. Its string is stable and safe to put on a wire.
const ( MultiLine Problem = "line" // A value holding a line break. NotBool Problem = "bool" // Neither true nor false. NotInteger Problem = "whole_number" // Also a TOML integer with a leading zero. NotNumber Problem = "number" // Also NaN and infinities. NotAllowed Problem = "enum" // Not one of Values. OutOfRange Problem = "range" // The file's range, the .NET type's, or Decimal's exact bound. NotColor Problem = "color" // Not 3, 4, 6 or 8 hex digits. NotList Problem = "list" // A TOML array without its brackets. Empty Problem = "empty" // A TypeRaw value left blank. BreaksTOML Problem = "toml" // Melon: the edit would leave a file that parsed unparsable. )
The reasons Set refuses a value.
type Type ¶
type Type string
Type is how an entry's value is written and validated.
const ( TypeBool Type = "bool" TypeInt Type = "int" TypeFloat Type = "float" TypeEnum Type = "enum" TypeString Type = "string" TypeColor Type = "color" TypeList Type = "list" // TypeRaw is a Melon value the parser cannot type (an inline table, a date, a hex integer): its TOML text is // shown and written as typed, never quoted. TypeRaw Type = "raw" )
The entry types. TypeRaw is a Melon value the parser cannot type.
type ValueError ¶
type ValueError struct {
Key string
Problem Problem
// Min and Max are the bound broken for OutOfRange, from the file or the .NET type; either may be nil.
Min, Max *float64
Values []string // The acceptable values for NotAllowed.
}
ValueError is a value Set refuses. Error is a plain English sentence naming the key, for logs and CLIs; callers word their own sentence for people from Problem and the bounds.
func (*ValueError) Error ¶
func (e *ValueError) Error() string
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ini sets `key = value` lines in an ini-style file's text, leaving every other byte as it was.
|
Package ini sets `key = value` lines in an ini-style file's text, leaving every other byte as it was. |
|
internal
|
|
|
textdoc
Package textdoc splits text into lines that remember their own ending, so an edit rewrites one line and every other byte comes back as it was.
|
Package textdoc splits text into lines that remember their own ending, so an edit rewrites one line and every other byte comes back as it was. |
|
Package jsonfile edits one value in a mod's JSON config file while keeping its key order and every other value as written.
|
Package jsonfile edits one value in a mod's JSON config file while keeping its key order and every other value as written. |
|
Package msbuild edits MSBuild files (.csproj, .props, .targets) in place: it parses them to find each element's exact bytes, then changes only those, so the developer's formatting, comments and attribute order stay as they wrote them.
|
Package msbuild edits MSBuild files (.csproj, .props, .targets) in place: it parses them to find each element's exact bytes, then changes only those, so the developer's formatting, comments and attribute order stay as they wrote them. |