Class Context

pkgxx/context.moon

pkgxx’ main class.

The Context is a shared environment in which packages are built with a specific configuration and for a given package manager.

Its most-used method is probably newRecipe.

Constructors

Context ! Context

Context constructor.

Return values
TypeDescription
Context

Instance

importConfiguration (filename) nil

Loads the system-wide pkg++ configuration, usually stored in /etc/pkg++.conf.

Arguments
ArgumentTypeDescription
filenamestringPath to a configuration file to load instead of the default one.
Return values
TypeDescription
nil

loadModules ! nil

Loads the default pkg++ modules, installed in the system directories. Those directories are usually /usr/share/pkgxx and its /usr/local variant.

Return values
TypeDescription
nil
Warning
Modules from the `./modules` directories are also currently loaded, for development reasons.
Issue
Broken modules will likely throw errors.

loadModule (content) nil

Creates a module and loads it into the Context.

This methods allows the dynamic creation of modules in pkg++.

Arguments
ArgumentTypeDescription
contenttableModule content.
Return values
TypeDescription
nil
See also
Module

checkConfiguration ! nil

Prints warnings on stderr if important configuration elements are missing.

Return values
TypeDescription
nil

newRecipe ! Recipe

Creates a new empty Recipe object.

The only difference with the default Recipe constructor is that the current Context is provided.

Return values
TypeDescription
Recipe

openRecipe (filename = "package.toml") object

Creates a Recipe object from a package.toml file.

Arguments
ArgumentTypeDescription
filenamestringFilename of the package.toml to read and parse into a Recipe.
See also
Recipe
Warning
This method is deprecated. Use newRecipe instead.

isAtomInstalled (atom) boolean

Asks the package manager whether a given package Atom is installed.

Arguments
ArgumentTypeDescription
atomAtomAtom describing a package whose installation is being tested.
Return values
TypeDescription
booleanWhether the atom installed or not.
See also
Atom

updateRepository (opt) boolean | nil

Updates the context’s packages repository.

It can be used to register several new packages at once.

Arguments
ArgumentTypeDescription
opttableOptions to provide to the repository manager’s module.
Return values
TypeDescription
booleanValue returned by the repository manager’s module.
nilNo module could be used to update the repository.

addToRepository (target, opt) boolean | nil

Adds a package to the context’s repository.

Arguments
ArgumentTypeDescription
targetstringFilename of the package to add to the repository.
opttableOptions to provide to the repository manager’s module.
Return values
TypeDescription
booleanValue returned by the repository manager’s module.
nilNo module could be used to update the repository.

close ! object

Closes the context.

Warning
This method removes the context's temporary files.

__tostring ! object


prefixes: { 12 elements }

Array of prefix names. Used for macro substitutions and for some auto-configuration within modules.

[1]: "prefix"
[2]: "bindir"
[3]: "sharedir"
[4]: "infodir"
[5]: "mandir"
[6]: "docdir"
[7]: "libdir"
[8]: "libexecdir"
[9]: "includedir"
[10]: "confdir"
[11]: "statedir"
[12]: "opt"

getPrefix (name) object

Gets the current path for a specific prefix.

Arguments
ArgumentTypeDescription
namestringOne of the values in @prefixes.