Skip to content

Commit

Permalink
use latest glint
Browse files Browse the repository at this point in the history
  • Loading branch information
TanklesXL committed Mar 7, 2024
1 parent acfe038 commit a372464
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions gleam.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name = "gladvent"
version = "0.7.0"
version = "0.7.1"
repository = { type = "github", user = "TanklesXL", repo = "gladvent" }
description = "An Advent Of Code runner for gleam"
licences = ["Apache-2.0"]
internal_modules = ["gladvent/internal/*"]
gleam = "~> 1.0"

[dependencies]
glint = "~> 0.17.1"
glint = "~> 0.18"
simplifile = "~> 0.3"
argv = "~> 1.0"
shellout = "~> 1.6"
Expand Down
4 changes: 2 additions & 2 deletions manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ packages = [
{ name = "gleam_stdlib", version = "0.36.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "C0D14D807FEC6F8A08A7C9EF8DFDE6AE5C10E40E21325B2B29365965D82EB3D4" },
{ name = "glearray", version = "0.2.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "glearray", source = "hex", outer_checksum = "908154F695D330E06A37FAB2C04119E8F315D643206F8F32B6A6C14A8709FFF4" },
{ name = "gleeunit", version = "1.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "D364C87AFEB26BDB4FB8A5ABDE67D635DC9FA52D6AB68416044C35B096C6882D" },
{ name = "glint", version = "0.17.1", build_tools = ["gleam"], requirements = ["gleam_community_ansi", "gleam_community_colour", "gleam_stdlib", "snag"], otp_app = "glint", source = "hex", outer_checksum = "DF094D7A97C54F4A23F670A7109A188DCBBDD17E003B3E650566835BDBA6BFDF" },
{ name = "glint", version = "0.18.0", build_tools = ["gleam"], requirements = ["gleam_community_ansi", "gleam_community_colour", "gleam_stdlib", "snag"], otp_app = "glint", source = "hex", outer_checksum = "BB0F14643CC51C069A5DC6E9082EAFCD9967AFD1C9CC408803D1A40A3FD43B54" },
{ name = "repeatedly", version = "2.1.1", build_tools = ["gleam"], requirements = [], otp_app = "repeatedly", source = "hex", outer_checksum = "38808C3EC382B0CD981336D5879C24ECB37FCB9C1D1BD128F7A80B0F74404D79" },
{ name = "shellout", version = "1.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "shellout", source = "hex", outer_checksum = "E2FCD18957F0E9F67E1F497FC9FF57393392F8A9BAEAEA4779541DE7A68DD7E0" },
{ name = "simplifile", version = "0.4.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "8F3C94B83F691CCFACD784A4D7C1F7E5A0437D93341549B908EE3B32E3477447" },
Expand All @@ -29,7 +29,7 @@ gleam_otp = { version = "~> 0.4" }
gleam_package_interface = { version = "~> 1.0" }
gleam_stdlib = { version = "~> 0.36 or ~> 1.0" }
gleeunit = { version = "~> 1.0" }
glint = { version = "~> 0.17.1" }
glint = { version = "~> 0.18" }
shellout = { version = "~> 1.6" }
simplifile = { version = "~> 0.3" }
snag = { version = "~> 0.2" }
Expand Down
14 changes: 10 additions & 4 deletions src/gladvent.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@ pub fn main() {
glint.new()
|> glint.with_name("gladvent")
|> glint.as_gleam_module
|> glint.global_flag(cmd.year, cmd.year_flag())
|> glint.group_flag(at: [], for: cmd.year, of: cmd.year_flag())
|> glint.with_pretty_help(glint.default_pretty_help())
|> glint.add(["new"], new.new_command())
|> glint.add(["run"], run.run_command())
|> glint.add(["run", "all"], run.run_all_command())
|> glint.add(at: ["new"], do: new.new_command())
|> glint.group_flag(at: ["run"], for: run.timeout, of: run.timeout_flag())
|> glint.group_flag(
at: ["run"],
for: run.allow_crash,
of: run.allow_crash_flag(),
)
|> glint.add(at: ["run"], do: run.run_command())
|> glint.add(at: ["run", "all"], do: run.run_all_command())

use out <- glint.run_and_handle(commands, argv.load().arguments)
case out {
Expand Down
12 changes: 4 additions & 8 deletions src/gladvent/internal/cmd/run.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,11 @@ fn collect(year: Int, x: #(Day, RunResult)) -> String {

// ----- CLI -----

const timeout = "timeout"
pub const timeout = "timeout"

const allow_crash = "allow-crash"
pub const allow_crash = "allow-crash"

fn timeout_flag() {
pub fn timeout_flag() {
flag.int()
|> flag.constraint(fn(i) {
case i > 0 {
Expand All @@ -248,7 +248,7 @@ fn timeout_flag() {
|> flag.description("Run with specified timeout")
}

fn allow_crash_flag() {
pub fn allow_crash_flag() {
flag.bool()
|> flag.default(False)
|> flag.description("Don't catch exceptions thrown by runners")
Expand Down Expand Up @@ -277,8 +277,6 @@ pub fn run_command() -> glint.Command(Result(List(String))) {
))
|> Ok
}
|> glint.flag(timeout, timeout_flag())
|> glint.flag(allow_crash, allow_crash_flag())
|> glint.description("Run the specified days")
|> glint.unnamed_args(glint.MinArgs(1))
}
Expand Down Expand Up @@ -316,8 +314,6 @@ pub fn run_all_command() -> glint.Command(Result(List(String))) {
))
|> Ok
}
|> glint.flag(timeout, timeout_flag())
|> glint.flag(allow_crash, allow_crash_flag())
|> glint.description("Run all registered days")
|> glint.unnamed_args(glint.EqArgs(0))
}

0 comments on commit a372464

Please sign in to comment.