Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update gleam_stdlib and glint version #577

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gleam/gleam.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ version = "1.0.0"
# https://gleam.run/writing-gleam/gleam-toml/.

[dependencies]
gleam_stdlib = ">= 0.38.0 and < 1.0.0"
glint = ">= 0.18.1 and < 1.0.0"
gleam_stdlib = ">= 0.42.0 and < 1.0.0"
glint = ">= 1.1.0 and < 2.0.0"
argv = ">= 1.0.2 and < 2.0.0"

[dev-dependencies]
Expand Down
16 changes: 7 additions & 9 deletions gleam/src/program.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,30 @@ import gleam/io
import gleam/list
import gleam/string
import glint
import glint/flag

pub fn main() {
run_cli_app(update_quality)
}

pub fn run_cli_app(modify_inventory: fn(GildedRose) -> GildedRose) {
let days_flag = "days"
let days_flag = glint.int_flag("days")

let number_of_days =
flag.int()
|> flag.default(2)
|> flag.description("Number of days")
days_flag
|> glint.flag_default(2)
|> glint.flag_help("Number of days")

let simulate_inventory = fn() {
use input <- glint.command()
use _, _, flags <- glint.command()

let assert Ok(number_of_days) =
flag.get_int(from: input.flags, for: days_flag)
let assert Ok(number_of_days) = glint.get_flag(from: flags, for: days_flag)
simulate(number_of_days, modify_inventory)
}

let app =
glint.new()
|> glint.with_name("Gilded Rose")
|> glint.group_flag([], days_flag, number_of_days)
|> glint.group_flag([], number_of_days)
|> glint.add(at: [], do: simulate_inventory())

io.println("OMGHAI!")
Expand Down