Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brettkolodny/gleam-hug
A package for creating helpful, and pretty CLI messages.
https://github.com/brettkolodny/gleam-hug
Last synced: 27 days 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 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-31T15:49:09.000Z (12 months ago)
- Last Synced: 2024-03-15T08:05:53.124Z (9 months ago)
- Language: Gleam
- Size: 35.2 KB
- Stars: 20
- Watchers: 1
- Forks: 0
- 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.
[![Package Version](https://img.shields.io/hexpm/v/hug)](https://hex.pm/packages/hug)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](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 hugpub 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".