Packages
glint
0.3.0
1.3.0
1.2.1
1.2.0
1.1.1
1.1.0
1.0.1
1.0.0
1.0.0-rc5
1.0.0-rc4
1.0.0-rc3
1.0.0-rc2
1.0.0-rc1
0.18.1
0.18.0
0.17.1
0.17.0
0.16.0
0.16.0-rc1
0.15.0
0.15.0-rc2
0.15.0-rc1
0.14.0
0.13.0
0.12.0
0.12.0-rc6
0.12.0-rc5
0.12.0-rc4
0.12.0-rc3
0.12.0-rc2
0.12.0-rc1
0.11.4
0.11.3
0.11.2
0.11.0
0.10.0
0.9.0
0.8.0
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0
0.6.0
0.5.0
0.4.0
0.3.0
0.2.0
0.1.3
0.1.2
0.1.1
0.1.0
Gleam command-line argument parsing with flags and automated help text generation.
Current section
Files
Jump to
Current section
Files
README.md
# glint
<a href="https://github.com/TanklesXL/glint/releases"><img src="https://img.shields.io/github/release/TanklesXL/glint.svg" alt="GitHub release"></a>
Gleam command line argument parsing with basic flag support.
Find glint on [hex.pm](https://hex.pm/packages/glint).
Find the glint docs on [hexdocs.pm](https://hexdocs.pm/glint/)
## Installation
To install from hex:
```sh
gleam add glint
```
## Usage
You can import `glint` as a dependency and use it as follows:
```rust
import gleam/io
import gleam/map
import gleam/erlang.{start_arguments}
import glint.{CommandInput}
import glint/flag
pub fn main() {
let hello_world = fn(input: CommandInput) {
assert Ok(flag.B(caps)) = map.get(input.flags, "caps")
case caps {
True -> io.println("HELLO, WORLD!")
False -> io.println("Hello, World!")
}
}
glint.new()
|> glint.add_command([], hello_world, [flag.string("caps", False)])
|> glint.run(start_arguments())
}
```
Run it with either of:
- `gleam run` which will print `Hello, World!`
- `gleam run -- --caps=true` which will print `HELLO, WORLD!`