Pack

A tool for downloading Gleam packages!

Package Version Hex Docs

Pack is a tool for downloading Gleam packages using the Gleam package index and Hex.

As a CLI tool

Pack can be used as a standalone CLI tool. Either clone the repository, or download the latest escript build from the releases page.

Running pack download will download all Gleam packages from Hex to your disc, or you can use pack fetch to simply fetch data from the package index without downloading any code.

Run pack help for a detailed description of commands and flags.

As a library

Pack is somewhat of an unconventional library, as it includes side-effect producing code, including HTTP requests and writing files to disc. However, it can be useful for applications which need to process a large set of Gleam packages, for example search.

Here’s some example code using pack as a library:

import gleam/io
import pack

pub fn main() {
  let assert Ok(pack) = pack.load(pack.default_options)
  let assert Ok(packages) = pack.download(pack)

  dict.each(packages, fn(name, files) {
    let list_of_files =
      files
      |> list.map(fn(file) { file.name })
      |> string.join(", ")
    io.println(
      "Package " <> name <> " has the following files: " <> list_of_files,
    )
  })
}
Search Document