Skip to content

Commit 422f676

Browse files
committed
Support gleam_stdlib v1.0
1 parent bdf598f commit 422f676

File tree

15 files changed

+260
-256
lines changed

15 files changed

+260
-256
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ jobs:
1515

1616
- uses: erlef/setup-beam@v1
1717
with:
18-
otp-version: "25"
18+
otp-version: "26"
1919
rebar3-version: "3"
20-
gleam-version: "0.33"
20+
gleam-version: "1.0.0-rc2"
2121

2222
- uses: denoland/setup-deno@v1
2323
with:

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
- Rad now supports `gleam_stdlib` v1.0.
6+
- Rad now requires Gleam v0.34 or later.
7+
- Rad now requires `glint` v0.15 or later.
8+
39
## v1.0.0 - 2023-12-21
410

511
- Rad now requires Gleam v0.33 or later.

gleam.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name = "rad"
2-
version = "1.0.0"
2+
version = "1.1.0-dev"
33
description = "A task runner for Gleam projects"
44
licences = ["Apache-2.0"]
55
target = "javascript"
6-
gleam = ">= 0.33.0"
6+
gleam = ">= 0.34.0"
77

88
[repository]
99
repo = "rad"
@@ -16,13 +16,13 @@ title = "Website"
1616

1717
[dependencies]
1818
gleam_http = "~> 3.5"
19-
gleam_json = "~> 0.7"
20-
gleam_stdlib = "~> 0.34"
21-
glint = "~> 0.13"
22-
shellout = "~> 1.5"
23-
snag = "~> 0.3"
24-
thoas = "~> 0.4"
25-
tomerl = "~> 0.5"
19+
gleam_json = "~> 0.7 or ~> 1.0"
20+
gleam_stdlib = "~> 0.34 or ~> 1.0"
21+
glint = "~> 0.15 or ~> 1.0"
22+
shellout = "~> 1.6"
23+
snag = "~> 0.3 or ~> 1.0"
24+
thoas = "~> 0.4 or ~> 1.0"
25+
tomerl = "~> 0.5 or ~> 1.0"
2626

2727
[dev-dependencies]
2828
gleeunit = "~> 1.0"

manifest.toml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22
# You typically do not need to edit this file
33

44
packages = [
5-
{ name = "gleam_community_ansi", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_community_colour"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "8B5A9677BC5A2738712BBAF2BA289B1D8195FDF962BBC769569976AD5E9794E1" },
6-
{ name = "gleam_community_colour", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "036C206886AFB9F153C552700A7A0B4D2864E3BC96A20C77E5F34A013C051BE3" },
7-
{ name = "gleam_http", version = "3.5.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "AECDA43AFD523D07A8F09068598A6E271C505278A0CB6F9C7A2E4365EAE8D11E" },
8-
{ name = "gleam_json", version = "0.7.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "thoas"], otp_app = "gleam_json", source = "hex", outer_checksum = "CB405BD93A8828BCD870463DE29375E7B2D252D9D124C109E5B618AAC00B86FC" },
9-
{ name = "gleam_stdlib", version = "0.34.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "1FB8454D2991E9B4C0C804544D8A9AD0F6184725E20D63C3155F0AEB4230B016" },
5+
{ name = "gleam_community_ansi", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_stdlib"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "FE79E08BF97009729259B6357EC058315B6FBB916FAD1C2FF9355115FEB0D3A4" },
6+
{ name = "gleam_community_colour", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "A49A5E3AE8B637A5ACBA80ECB9B1AFE89FD3D5351FF6410A42B84F666D40D7D5" },
7+
{ name = "gleam_http", version = "3.5.3", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "C2FC3322203B16F897C1818D9810F5DEFCE347F0751F3B44421E1261277A7373" },
8+
{ name = "gleam_json", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "thoas"], otp_app = "gleam_json", source = "hex", outer_checksum = "8B197DD5D578EA6AC2C0D4BDC634C71A5BCA8E7DB5F47091C263ECB411A60DF3" },
9+
{ name = "gleam_stdlib", version = "0.35.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "81E91937710732ED1CA1F8E83D7AD19B4E87F63A1FC644A539264B6A118003D4" },
1010
{ name = "gleeunit", version = "1.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "D364C87AFEB26BDB4FB8A5ABDE67D635DC9FA52D6AB68416044C35B096C6882D" },
11-
{ name = "glint", version = "0.13.0", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_community_ansi", "gleam_stdlib", "snag"], otp_app = "glint", source = "hex", outer_checksum = "46E56049CD370D61F720D319D0AB970408C9336EEB918F08B5DCB1DCE9845FA3" },
12-
{ name = "shellout", version = "1.5.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "shellout", source = "hex", outer_checksum = "7B5DE499DBB3DDC25051FC1BB3770DD5466938B6A2AFA91A6FB4A4D49F4CB0D4" },
11+
{ name = "glint", version = "0.15.0", build_tools = ["gleam"], requirements = ["gleam_community_ansi", "gleam_community_colour", "gleam_stdlib", "snag"], otp_app = "glint", source = "hex", outer_checksum = "D5324DBE11F57BF0B303D99EA086D66B8DC319EE59C1355C76EBB1544187C237" },
12+
{ name = "shellout", version = "1.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "shellout", source = "hex", outer_checksum = "E2FCD18957F0E9F67E1F497FC9FF57393392F8A9BAEAEA4779541DE7A68DD7E0" },
1313
{ name = "snag", version = "0.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "snag", source = "hex", outer_checksum = "54D32E16E33655346AA3E66CBA7E191DE0A8793D2C05284E3EFB90AD2CE92BCC" },
1414
{ name = "thoas", version = "0.4.1", build_tools = ["rebar3"], requirements = [], otp_app = "thoas", source = "hex", outer_checksum = "4918D50026C073C4AB1388437132C77A6F6F7C8AC43C60C13758CC0ADCE2134E" },
1515
{ name = "tomerl", version = "0.5.0", build_tools = ["rebar3"], requirements = [], otp_app = "tomerl", source = "hex", outer_checksum = "2A7FB62F9EBF0E75561B39255638BC2B805B437C86FEC538657E7C3B576979FA" },
1616
]
1717

1818
[requirements]
1919
gleam_http = { version = "~> 3.5" }
20-
gleam_json = { version = "~> 0.7" }
21-
gleam_stdlib = { version = "~> 0.34" }
20+
gleam_json = { version = "~> 0.7 or ~> 1.0" }
21+
gleam_stdlib = { version = "~> 0.34 or ~> 1.0" }
2222
gleeunit = { version = "~> 1.0" }
23-
glint = { version = "~> 0.13" }
24-
shellout = { version = "~> 1.5" }
25-
snag = { version = "~> 0.3" }
26-
thoas = { version = "~> 0.4" }
27-
tomerl = { version = "~> 0.5" }
23+
glint = { version = "~> 0.15 or ~> 1.0" }
24+
shellout = { version = "~> 1.6" }
25+
snag = { version = "~> 0.3 or ~> 1.0" }
26+
thoas = { version = "~> 0.4 or ~> 1.0" }
27+
tomerl = { version = "~> 0.5 or ~> 1.0" }

src/rad.gleam

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ pub fn main() -> Nil {
4040
|> glint.add(
4141
at: [],
4242
do: fn(input: CommandInput) {
43-
"with"
44-
|> flag.get_string(from: input.flags)
45-
|> result.unwrap(or: with)
46-
}
47-
|> glint.command
48-
|> glint.flag(
49-
at: "with",
50-
of: flag.string()
51-
|> flag.default(of: with),
52-
),
43+
"with"
44+
|> flag.get_string(from: input.flags)
45+
|> result.unwrap(or: with)
46+
}
47+
|> glint.command
48+
|> glint.flag(
49+
at: "with",
50+
of: flag.string()
51+
|> flag.default(of: with),
52+
),
5353
)
5454
|> glint.execute(arguments(Global))
5555

@@ -96,9 +96,9 @@ pub fn do_main(workbook: Workbook) -> Nil {
9696
|> glint.add(
9797
at: path,
9898
do: task.run(_, task)
99-
|> glint.command
100-
|> glint.flags(with: task.flags)
101-
|> glint.description(task.shortdoc),
99+
|> glint.command
100+
|> glint.flags(with: task.flags)
101+
|> glint.description(task.shortdoc),
102102
)
103103
})
104104
|> glint.execute(arguments(Normal))

src/rad/task.gleam

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import gleam
1010
import gleam/bool
11+
import gleam/dict
1112
import gleam/dynamic
1213
import gleam/int
1314
import gleam/json
@@ -169,9 +170,9 @@ pub fn flag(
169170
let flag = #(
170171
name,
171172
flag_fun()
172-
|> flag.default(of: value)
173-
|> flag.description(of: description)
174-
|> flag.build,
173+
|> flag.default(of: value)
174+
|> flag.description(of: description)
175+
|> flag.build,
175176
)
176177
let flags =
177178
task.flags
@@ -322,6 +323,8 @@ pub fn or(
322323
}
323324
}
324325

326+
let named_args = dict.new()
327+
325328
let mapper = fn(input: CommandInput, task, index, item) {
326329
case cond(input) {
327330
Each(map: mapper, ..) -> mapper(input, task, index, item)
@@ -330,7 +333,7 @@ pub fn or(
330333
item
331334
|> json.decode(using: dynamic.list(of: dynamic.string))
332335
|> result.unwrap(or: [])
333-
|> CommandInput(flags: input.flags)
336+
|> CommandInput(flags: input.flags, named_args: named_args)
334337
}
335338
}
336339
}
@@ -384,8 +387,10 @@ pub type Formatter {
384387
pub fn formatters() -> Iterable(a) {
385388
let formatters = [
386389
"gleam"
387-
|> Formatter(check: ["gleam", "format", "--check"], run: ["gleam", "format"])
388-
|> Ok,
390+
|> Formatter(check: ["gleam", "format", "--check"], run: [
391+
"gleam", "format",
392+
])
393+
|> Ok,
389394
..formatters_from_config()
390395
]
391396

@@ -394,6 +399,8 @@ pub fn formatters() -> Iterable(a) {
394399
|> list.map(with: fn(_result) { "" })
395400
}
396401

402+
let named_args = dict.new()
403+
397404
let mapper = fn(input: CommandInput, _task, index, _argument) {
398405
let io_println = util.quiet_or_println(input)
399406
let check =
@@ -414,7 +421,7 @@ pub fn formatters() -> Iterable(a) {
414421
let _print =
415422
[
416423
action
417-
|> shellout.style(with: shellout.color(["magenta"]), custom: []),
424+
|> shellout.style(with: shellout.color(["magenta"]), custom: []),
418425
" ",
419426
formatter.name,
420427
extra,
@@ -423,13 +430,13 @@ pub fn formatters() -> Iterable(a) {
423430
|> string.concat
424431
|> io_println
425432
args
426-
|> CommandInput(flags: input.flags)
433+
|> CommandInput(flags: input.flags, named_args: named_args)
427434
}
428435
_else ->
429436
"--fail"
430437
|> flag.update_flags(in: input.flags)
431438
|> result.unwrap(or: input.flags)
432-
|> CommandInput(args: [])
439+
|> CommandInput(args: [], named_args: named_args)
433440
}
434441
}
435442

@@ -520,7 +527,7 @@ pub fn targets() -> Iterable(a) {
520527
let _heading =
521528
[
522529
" Targeting"
523-
|> shellout.style(with: shellout.color(["magenta"]), custom: []),
530+
|> shellout.style(with: shellout.color(["magenta"]), custom: []),
524531
" ",
525532
target,
526533
"...",
@@ -672,7 +679,7 @@ pub fn trainer(runner: Runner(Result)) -> Runner(Result) {
672679
|> int.to_string
673680
[
674681
errors
675-
|> int.to_string,
682+
|> int.to_string,
676683
"of",
677684
results,
678685
"task runs failed",

src/rad/toml.gleam

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ fn do_decode_every(
7373
|> decode(
7474
from: toml,
7575
expect: dynamic.from
76-
|> function.compose(dynamic.dict(of: dynamic.string, to: dynamic.dynamic)),
76+
|> function.compose(dynamic.dict(
77+
of: dynamic.string,
78+
to: dynamic.dynamic,
79+
)),
7780
),
7881
)
7982

src/rad/util.gleam

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,11 @@ pub fn snag_pretty_print(snag: Snag) -> String {
323323
let builder =
324324
[
325325
"error"
326-
|> bold(and: ["red"]),
326+
|> bold(and: ["red"]),
327327
": "
328-
|> bold([]),
328+
|> bold([]),
329329
snag.issue
330-
|> bold([]),
330+
|> bold([]),
331331
"\n",
332332
]
333333
|> string_builder.from_strings
@@ -338,9 +338,9 @@ pub fn snag_pretty_print(snag: Snag) -> String {
338338
[
339339
"\n",
340340
"cause"
341-
|> bold(and: ["red"]),
341+
|> bold(and: ["red"]),
342342
":\n"
343-
|> bold([]),
343+
|> bold([]),
344344
]
345345
|> string_builder.from_strings
346346
|> string_builder.append_builder(to: builder)
@@ -355,12 +355,12 @@ fn pretty_print_cause(cause) {
355355
[
356356
" ",
357357
index
358-
|> int.to_string
359-
|> bold(and: ["red"]),
358+
|> int.to_string
359+
|> bold(and: ["red"]),
360360
": "
361-
|> bold([]),
361+
|> bold([]),
362362
line
363-
|> bold([]),
363+
|> bold([]),
364364
"\n",
365365
]
366366
|> string.concat
@@ -372,7 +372,7 @@ fn bold(string, and colors: List(String)) -> String {
372372
string
373373
|> shellout.style(
374374
with: shellout.display(["bold"])
375-
|> dict.merge(from: shellout.color(colors)),
375+
|> dict.merge(from: shellout.color(colors)),
376376
custom: lookups,
377377
)
378378
}

src/rad/workbook.gleam

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,16 @@ pub fn help(from workbook_fun: fn() -> Workbook) -> Runner(Result) {
167167
#(
168168
"help",
169169
flag.bool()
170-
|> flag.default(of: False)
171-
|> flag.description(of: "Print help information")
172-
|> flag.build,
170+
|> flag.default(of: False)
171+
|> flag.description(of: "Print help information")
172+
|> flag.build,
173173
),
174174
#(
175175
"with",
176176
flag.string()
177-
|> flag.default(of: "")
178-
|> flag.description(of: "Specify a rad runtime")
179-
|> flag.build,
177+
|> flag.default(of: "")
178+
|> flag.description(of: "Specify a rad runtime")
179+
|> flag.build,
180180
),
181181
..task.flags
182182
|> list.filter(keeping: fn(flag) {
@@ -211,7 +211,7 @@ pub fn help(from workbook_fun: fn() -> Workbook) -> Runner(Result) {
211211
|> string.join(with: " ")
212212
|> shellout.style(
213213
with: shellout.display(["bold"])
214-
|> dict.merge(from: shellout.color([path_color])),
214+
|> dict.merge(from: shellout.color([path_color])),
215215
custom: util.lookups,
216216
)
217217
|> Some
@@ -256,7 +256,7 @@ pub fn help(from workbook_fun: fn() -> Workbook) -> Runner(Result) {
256256
"rad"
257257
|> shellout.style(
258258
with: shellout.display(["bold"])
259-
|> dict.merge(from: shellout.color(["pink"])),
259+
|> dict.merge(from: shellout.color(["pink"])),
260260
custom: util.lookups,
261261
)
262262
|> Some
@@ -336,7 +336,7 @@ pub fn info(config: Toml) -> Result {
336336
"rad"
337337
|> shellout.style(
338338
with: shellout.display(["bold", "italic"])
339-
|> dict.merge(from: shellout.color(["pink"])),
339+
|> dict.merge(from: shellout.color(["pink"])),
340340
custom: util.lookups,
341341
)
342342
|> Some
@@ -360,19 +360,19 @@ pub fn info(config: Toml) -> Result {
360360
|> result.map(with: shellout.style(
361361
_,
362362
with: shellout.display(["italic"])
363-
|> dict.merge(from: shellout.color(["purple"])),
363+
|> dict.merge(from: shellout.color(["purple"])),
364364
custom: util.lookups,
365365
))
366366
|> option.from_result
367367

368368
[
369369
[name, version]
370-
|> option.values
371-
|> string.join(with: " ")
372-
|> Some,
370+
|> option.values
371+
|> string.join(with: " ")
372+
|> Some,
373373
[Some(""), description]
374-
|> option.all
375-
|> option.map(with: string.join(_, with: tab)),
374+
|> option.all
375+
|> option.map(with: string.join(_, with: tab)),
376376
]
377377
|> option.values
378378
|> string.join(with: "\n")
@@ -385,7 +385,7 @@ pub fn heading(name: String) -> String {
385385
name
386386
|> shellout.style(
387387
with: shellout.display(["bold"])
388-
|> dict.merge(from: shellout.color([heading_color])),
388+
|> dict.merge(from: shellout.color([heading_color])),
389389
custom: util.lookups,
390390
)
391391
}

0 commit comments

Comments
 (0)