Using metis in your own projects

The simplest way to use metis is just to copy and paste individual functions or modules into your own project. However, there's a couple of other ways too:

Custom module loader:

Paste the following code block on the top of your program. Then just use require to load any metis-specific modules.

local modules = {
  ["metis.argparse"] = "ce85126f53072170ac90adb808cd4dc507098aa8",
  ["metis.async"] = "ef222d5cdd0d567ef2a70685151f42434da78dea",
  ["metis.crypto.sha1"] = "5fb4c5b225c0cb4bdd395c624537bca65a41906f",
  ["metis.fs"] = "55e8c20a5f31e94de754f85aa053eabfc3163f66",
  ["metis.input.keybinding"] = "874c65de209df5c9489a47b9dc4cd11795b65dd1",
  ["metis.input.readline"] = "99efbe5a77a78cef85a4b7df97e76856ab272f45",
  ["metis.math"] = "2a9eb4b2b00f9d9c1ff5693047cdbc8e9719ba05",
  ["metis.string"] = "028b9baa83554ab3d231627363e7e07df5c34c8b",
  ["metis.string.fuzzy"] = "5eac743391346dc1b2c449b6570491b4c1b65974",
  ["metis.timer"] = "d6ac8836a76776d6e165f7d101e221ee50851c8a",
}
package.loaders[#package.loaders + 1] = function(name)
  local sha = modules[name]
  if not sha then return nil, "not a metis module" end
  local path = name:gsub("%.", "/") .. ".lua"

  local local_path = "/.cache/metis/" .. sha .. "/" .. path
  if not fs.exists(local_path) then
    local url = "https://raw.githubusercontent.com/SquidDev-CC/metis/" .. sha .. "/src/" .. path
    local request, err = http.get(url)
    if not request then return nil, "Cannot download " .. url .. ": " .. err end

    local out = fs.open(local_path, "w")
    out.write(request.readAll())
    out.close()

    request.close()
  end

  local fn, err = loadfile(local_path, nil, _ENV)
  if fn then return fn, local_path else return nil, err end
end

This registers a custom package loader which downloads (and caches) modules straight from GitHub.

Packman

  1. Install Packman: pastebin run 4zyreNZy
  2. Open a Lua REPL (run lua in the shell) and run the following code:
    io.open("/etc/custom-repolist", "a"):write("metis https://metis.madefor.cc/packlist"):close()
    
    Now exit the REPL with exit().
  3. Update repositories: packman fetch.
  4. Install metis: packman install metis/metis-full.