Skip to content

Commit

Permalink
Update to latest glint and gleam versions (#7)
Browse files Browse the repository at this point in the history
* refactor: update glint and make relevant modifications

* testing with glint 0.12.0-rc3

* wip: refactoring commands

* Deps

* use glint 0.12.0-rc6

* update to gleam 0.32.4

* switch to task.await_forever and task.await
  • Loading branch information
TanklesXL authored Nov 13, 2023
1 parent 5920515 commit 99ccae2
Show file tree
Hide file tree
Showing 20 changed files with 745 additions and 635 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
gleam: ["0.25.0"]
erlang: ["24.2"]
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/test
with:
gleam-version: ${{ matrix.gleam }}
erlang-version: ${{ matrix.erlang }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ logs
rebar3.crashdump
build
src/days
src/aoc_*
input
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
gleam 0.25.0
gleam 0.32.4
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ To add this library to your project run: `gleam add gladvent` and add `import gl

## Using the library

This library provides 2 options to run your advent of code solvers:
This library provides 3 options to run your advent of code solvers:

1. The easiest way: call it via `gleam run -m gladvent [ARGS]`, not requiring a custom `main()` function.
1. The easy way: simply add `gladvent.main()` to the end of your project's `main` function.
2. Create your own `Map(Int, #(fn(String) -> Dynamic, fn(String) -> Dynamic))` and pass it to `gladvent.execute`

## Multi-year support

Gladvent now comes with out-of-the-box multi-year support via the `--year` flag when running it. For convenience it defaults to the current year. Therefore, passing the `--year=YEAR`flag to either the`run`, `run all`or`new` commands will use the year specified or the current year if the flag was not provided.

## Available commands

Expand Down Expand Up @@ -44,10 +48,8 @@ This project provides your application with 2 commands, `new` and `run`:

_Note:_

- due to how `gladvent` works, the `pt_1` and `pt_2` functions only need to return `Dynamic` when directly building a `RunnerMap` and using `gladvent.execute`, when using `gladvent.main` they can return anything.
- the `new` command creates source files in `src/days/` and input files in the `input/` directory.
- the `run` command expects input files to be in the `input/` directory.
- using `gladvent.main` expects gleam day runners to be in `src/days/`
- the `new` command creates source files in `src/aoc_<YEAR>/` and input files in the `input/<YEAR>` directory.
- the `run` command expects input files to be in the `input/<YEAR>` directory, and code to be in `src/aoc_<YEAR>/`
- any triggered `assert` will be captured and printed, for example: `error: assert - Assertion pattern match failed in module days/day_1 in function pt_1 at line 2 with value 2`
- any message in a `todo` will be captured and printed, for example: `error: todo - test in module days/day_1 in function pt_2 at line 7`

Expand All @@ -64,10 +66,10 @@ Where X is the day you'd like to add (when using `gladvent.main()`):

_Note:_ this method requires all day solutions be in `src/days/` with filenames `day_X.gleam`, each solution module containing `fn pt_1(String) -> Int` and a `fn pt_2(String) -> Int`

1. run `gleam run new X`
2. add your input to `input/day_X.txt`
3. add your code to `src/days/day_X.gleam`
4. run `gleam run run X`
1. run `gleam run -m gladvent run new X`
2. add your input to `input/<YEAR>/day_X.txt`
3. add your code to `src/aoc_<YEAR>/day_X.gleam`
4. run `gleam run -m gladvent run X`

## FAQ

Expand Down
7 changes: 5 additions & 2 deletions gleam.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
name = "gladvent"
version = "0.5.1"
version = "0.6.0"
repository = { type = "github", user = "TanklesXL", repo = "gladvent" }
description = "An Advent Of Code runner for gleam"
licences = ["Apache-2.0"]
internal_modules = ["gladvent/internal/*", "aoc_*"]
gleam = ">= 0.32.0"

[dependencies]
gleam_stdlib = "~> 0.19"
gleam_otp = "~> 0.4"
gleam_erlang = "~> 0.7"
snag = "~> 0.2"
glint = "~> 0.8"
glint = " ~> 0.12"
simplifile = "~> 0.3"

[dev-dependencies]
gleeunit = "~> 0.6"
29 changes: 16 additions & 13 deletions manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@
# You typically do not need to edit this file

packages = [
{ name = "gleam_erlang", version = "0.17.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "A3BB3D4A6AFC2E34CAB1A4960F0CBBC4AA1A052D5023477D16B848D86E69948A" },
{ name = "gleam_otp", version = "0.5.2", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "24B88BF1D5B8DEC2525C00ECB65B96D2FD4DC66D8B2BB4D7AD4D12B2CE2A9988" },
{ name = "gleam_stdlib", version = "0.25.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "AD0F89928E0B919C8F8EDF640484633B28DBF88630A9E6AE504617A3E3E5B9A2" },
{ name = "gleeunit", version = "0.7.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "5F4FBED3E93CDEDB0570D30E9DECB7058C2D327996B78BB2D245C739C7136010" },
{ name = "glint", version = "0.10.0", build_tools = ["gleam"], requirements = ["shellout", "gleam_stdlib", "snag"], otp_app = "glint", source = "hex", outer_checksum = "540D6435A0CE5C3660769B364CFF9BC98724DF3ED942FA80946A47C653B4ED02" },
{ name = "shellout", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_erlang"], otp_app = "shellout", source = "hex", outer_checksum = "310662075CDCB6E3928B03E3FD371B1DDCD691E1C709E606AB02195E36675D4E" },
{ name = "snag", version = "0.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "snag", source = "hex", outer_checksum = "35C63E478782C58236F1050297C2FDF9806A4DD55C6FAF0B6EC5E54BC119342D" },
{ name = "gleam_community_ansi", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_stdlib"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "8B5A9677BC5A2738712BBAF2BA289B1D8195FDF962BBC769569976AD5E9794E1" },
{ name = "gleam_community_colour", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "036C206886AFB9F153C552700A7A0B4D2864E3BC96A20C77E5F34A013C051BE3" },
{ name = "gleam_erlang", version = "0.23.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "DA7A8E5540948DE10EB01B530869F8FF2FF6CAD8CFDA87626CE6EF63EBBF87CB" },
{ name = "gleam_otp", version = "0.8.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "18EF8242A5E54BA92F717C7222F03B3228AEE00D1F286D4C56C3E8C18AA2588E" },
{ name = "gleam_stdlib", version = "0.32.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "ABF00CDCCB66FABBCE351A50060964C4ACE798F95A0D78622C8A7DC838792577" },
{ name = "gleeunit", version = "0.11.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "1397E5C4AC4108769EE979939AC39BF7870659C5AFB714630DEEEE16B8272AD5" },
{ name = "glint", version = "0.12.0", build_tools = ["gleam"], requirements = ["gleam_community_ansi", "gleam_community_colour", "gleam_stdlib", "snag"], otp_app = "glint", source = "hex", outer_checksum = "799D6C76990EE1265396D7BEB5771AE902C3221AD79BA0B70A4FBADAEBAC1A1A" },
{ name = "simplifile", version = "0.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "45E2C6C7FD8D931A660CA56880EC75186BB39C84F36951B4EE284F6F95E8F65D" },
{ name = "snag", version = "0.2.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "snag", source = "hex", outer_checksum = "8FD70D8FB3728E08AC425283BB509BB0F012BE1AE218424A597CDE001B0EE589" },
]

[requirements]
gleam_erlang = "~> 0.7"
gleam_otp = "~> 0.4"
gleam_stdlib = "~> 0.19"
gleeunit = "~> 0.6"
glint = "~> 0.8"
snag = "~> 0.2"
gleam_erlang = { version = "~> 0.7" }
gleam_otp = { version = "~> 0.4" }
gleam_stdlib = { version = "~> 0.19" }
gleeunit = { version = "~> 0.6" }
glint = { version = " ~> 0.12" }
simplifile = { version = "~> 0.3" }
snag = { version = "~> 0.2" }
77 changes: 0 additions & 77 deletions src/cmd.gleam

This file was deleted.

149 changes: 0 additions & 149 deletions src/cmd/new.gleam

This file was deleted.

Loading

0 comments on commit 99ccae2

Please sign in to comment.