https://github.com/brettkolodny/gleam-hug
A package for creating helpful, and pretty CLI messages.
https://github.com/brettkolodny/gleam-hug
Last synced: 4 months ago
JSON representation
A package for creating helpful, and pretty CLI messages.
- Host: GitHub
- URL: https://github.com/brettkolodny/gleam-hug
- Owner: brettkolodny
- Created: 2023-01-22T18:16:14.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-01T15:15:03.000Z (over 1 year ago)
- Last Synced: 2025-07-24T12:52:59.978Z (4 months ago)
- Language: Gleam
- Size: 44.9 KB
- Stars: 31
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-gleam - hug - [📚](https://hexdocs.pm/hug/) - Helpful and pretty CLI messages (Packages / Text)
README
# hug
A package for creating helpful, and pretty CLI messages.
[](https://hex.pm/packages/hug)
[](https://hexdocs.pm/hug/)
✨ This project is written in pure Gleam so you can use it anywhere Gleam runs: Erlang, Elixir, Node, Deno, and the browser!
error: mismatched types
┌─ example.gleam:2:3
│
│ let a =
2 │ 1 + "hello"
│ ~~~~~~~~~~~
│
expected type `Num` got type `Str`
---
## Quick start
```gleam
import gleam/io
import hug
pub fn main() {
let source = "let six = 5 + 1.0"
source
|> hug.error(
in: "example.gleam",
from: #(1, 10),
to: #(1, 17),
message: "invalid type",
hint: "can not add an `Int` to a `Float`"
)
|> io.println_error()
}
```
## Installation
If available on Hex this package can be added to your Gleam project:
```sh
gleam add hug
```
and its documentation can be found at .
## Why `hug`?
The name `hug` is inspired by Mark Rendle's talk [The Worst Programming Language Ever](https://youtu.be/vcFBwt1nu2U?t=2229) where he refers error messages in Rust as "a hug from the compiler".