Documentation ¶
Overview ¶
Package mods contains helpers for working with Factorio mods.
Index ¶
- Constants
- func Categories() []string
- type Cache
- func (c *Cache) Clean() error
- func (c *Cache) Close() error
- func (c *Cache) DisableProgressBar()
- func (c *Cache) EnableProgressBar()
- func (c *Cache) Pull(ctx context.Context) error
- func (c *Cache) Search(ctx context.Context, searchTerm string, options ...SearchOption) ([]M, error)
- func (c *Cache) Update(ctx context.Context) error
- type Category
- type M
- type SearchOption
- type Version
Constants ¶
const ( NoCategory Category = "no-category" Content = "content" // Mods introducing new content into the game. Overhaul = "overhaul" // Large total conversion mods. Tweaks = "tweaks" // Small changes concerning balance, gameplay, or graphics. Utilities = "utilities" // Providing the player with new tools or adjusting the game interface, without fundamentally changing gameplay. Scenarios = "scenarios" // Scenarios, maps, puzzles. ModPacks = "mod-packs" // Collections of mods with tweaks to make them work together. Localizations = "localizations" // Translations for other mods. Internal = "internal" // Lua libraries for use by other mods and submods that are parts of a larger mod. )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a local database that is used for caching information about Factorio mods.
func (*Cache) DisableProgressBar ¶
func (c *Cache) DisableProgressBar()
func (*Cache) EnableProgressBar ¶
func (c *Cache) EnableProgressBar()
EnableProgressBar prints a progress bar to STDERR for methods like Cache.Pull, and Cache.Update.
func (*Cache) Pull ¶
Pull retrieves the mod list from the [Mods portal API], and caches the results, returning the path to the file holding the partially-processed results. The file holding the results contains a stream of mod entries, with each entry being its own JSON object. Use encoding/json.Decoder to read this file.
To update the cache database, call Cache.Update afterwards.
func (*Cache) Search ¶
func (c *Cache) Search(ctx context.Context, searchTerm string, options ...SearchOption) ([]M, error)
Search returns a list of mods matching the search term, with zero or more of the given options applied.
Search will return a non-nil error if the search term is an empty string, or if there is an error with any of the provided options.
type Category ¶
type Category string
Category is used to describe a mod. Mods can only belong to a single category.
type M ¶
type M struct { Name string `json:"name"` Enabled bool `json:"enabled"` // All of the currently-installed versions of the mod, sorted in // ascending order so the latest version is the last element in the // slice. Versions []Version `json:"-"` // The time at which the latest version was released. ReleasedAt time.Time `json:"-"` // A brief summary of the mod. Summary string `json:"-"` // The mod's category. Category string `json:"-"` }
type SearchOption ¶
type SearchOption func(*searchOptions) error
SearchOption is a functional option that can be passed to Cache.Search to adjust how searching is handled.
func NameOnly ¶
func NameOnly() SearchOption
NameOnly restricts the mod search to only match on a mod's name. By default, a mod's name and summary will be considered.
func RegexpTerm ¶
func RegexpTerm() SearchOption
RegexpTerm tells Cache.Search to treat the search term as a regular expression. When this option is provided, the search term will be compiled by regexp.Compile to ensure it is valid.
func SortByDate ¶
func SortByDate() SearchOption
SortByDate sorts the results by the date the latest version of the mod was released, in descending order (most-recently-released mod first).
func WithCategories ¶
func WithCategories(categories ...Category) SearchOption
WithCategories limits the results of a search to only return mods with the specified categories.