diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cafdfd..3e8a826 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Unreleased + +- Rad now requires `glint` v0.16 or later. + ## v1.1.0 - 2024-02-17 - Rad now uses npm package `smol-toml` for more feature-complete TOML parsing. diff --git a/gleam.toml b/gleam.toml index 2eb5640..9202939 100644 --- a/gleam.toml +++ b/gleam.toml @@ -1,5 +1,5 @@ name = "rad" -version = "1.1.0" +version = "1.2.0-dev" description = "A task runner for Gleam projects" licences = ["Apache-2.0"] target = "javascript" @@ -19,7 +19,7 @@ gleam_http = "~> 3.5" gleam_httpc = "~> 2.1" gleam_json = "~> 0.7 or ~> 1.0" gleam_stdlib = "~> 0.34 or ~> 1.0" -glint = "~> 0.15 or ~> 1.0" +glint = "~> 0.16 or ~> 1.0" shellout = "~> 1.6" snag = "~> 0.3 or ~> 1.0" thoas = "~> 0.4 or ~> 1.0" diff --git a/manifest.toml b/manifest.toml index 9b3a7dc..292d8ba 100644 --- a/manifest.toml +++ b/manifest.toml @@ -7,9 +7,9 @@ packages = [ { name = "gleam_http", version = "3.5.3", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "C2FC3322203B16F897C1818D9810F5DEFCE347F0751F3B44421E1261277A7373" }, { name = "gleam_httpc", version = "2.1.2", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_stdlib"], otp_app = "gleam_httpc", source = "hex", outer_checksum = "ACD05CA3BAC7780DF5FFAE334621FD199D1B490FAF6ECDFF74316CAA61CE88E6" }, { name = "gleam_json", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "thoas"], otp_app = "gleam_json", source = "hex", outer_checksum = "8B197DD5D578EA6AC2C0D4BDC634C71A5BCA8E7DB5F47091C263ECB411A60DF3" }, - { name = "gleam_stdlib", version = "0.35.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "5443EEB74708454B65650FEBBB1EF5175057D1DEC62AEA9D7C6D96F41DA79152" }, + { name = "gleam_stdlib", version = "0.36.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "C0D14D807FEC6F8A08A7C9EF8DFDE6AE5C10E40E21325B2B29365965D82EB3D4" }, { name = "gleeunit", version = "1.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "D364C87AFEB26BDB4FB8A5ABDE67D635DC9FA52D6AB68416044C35B096C6882D" }, - { 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" }, + { name = "glint", version = "0.16.0", build_tools = ["gleam"], requirements = ["gleam_community_ansi", "gleam_community_colour", "gleam_stdlib", "snag"], otp_app = "glint", source = "hex", outer_checksum = "61B7E85CBB0CCD2FD8A9C7AE06CA97A80BF6537716F34362A39DF9C74967BBBC" }, { name = "shellout", version = "1.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "shellout", source = "hex", outer_checksum = "E2FCD18957F0E9F67E1F497FC9FF57393392F8A9BAEAEA4779541DE7A68DD7E0" }, { name = "snag", version = "0.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "snag", source = "hex", outer_checksum = "54D32E16E33655346AA3E66CBA7E191DE0A8793D2C05284E3EFB90AD2CE92BCC" }, { name = "thoas", version = "0.4.1", build_tools = ["rebar3"], requirements = [], otp_app = "thoas", source = "hex", outer_checksum = "4918D50026C073C4AB1388437132C77A6F6F7C8AC43C60C13758CC0ADCE2134E" }, @@ -22,7 +22,7 @@ gleam_httpc = { version = "~> 2.1" } gleam_json = { version = "~> 0.7 or ~> 1.0" } gleam_stdlib = { version = "~> 0.34 or ~> 1.0" } gleeunit = { version = "~> 1.0" } -glint = { version = "~> 0.15 or ~> 1.0" } +glint = { version = "~> 0.16 or ~> 1.0" } shellout = { version = "~> 1.6" } snag = { version = "~> 0.3 or ~> 1.0" } thoas = { version = "~> 0.4 or ~> 1.0" } diff --git a/src/rad.gleam b/src/rad.gleam index e252217..3d46975 100644 --- a/src/rad.gleam +++ b/src/rad.gleam @@ -1,7 +1,5 @@ -import gleam/bool import gleam/dict import gleam/dynamic -import gleam/function import gleam/io import gleam/list import gleam/result @@ -108,6 +106,7 @@ pub fn do_main(workbook: Workbook) -> Nil { Help(string) -> Ok(string) } }) + |> result.map_error(with: snag.new) |> result.flatten |> end_task } @@ -123,9 +122,7 @@ fn arguments(scope: Scope) -> List(String) { start_arguments() |> list.filter(keeping: case scope { Global -> filter - Normal -> - filter - |> function.compose(bool.negate) + Normal -> fn(arg) { !filter(arg) } }) case scope { Global -> arguments diff --git a/src/rad/toml.gleam b/src/rad/toml.gleam index 2b888a4..df3cd18 100644 --- a/src/rad/toml.gleam +++ b/src/rad/toml.gleam @@ -14,8 +14,6 @@ import gleam/string import snag.{type Snag} @target(erlang) import gleam/dict -@target(erlang) -import gleam/function /// A TOML [table](https://toml.io/en/v1.0.0#table) of dynamic data. /// @@ -70,14 +68,11 @@ fn do_decode_every( ) -> Result(List(#(String, a)), Snag) { use dict <- result.try( key_path - |> decode( - from: toml, - expect: dynamic.from - |> function.compose(dynamic.dict( - of: dynamic.string, - to: dynamic.dynamic, - )), - ), + |> decode(from: toml, expect: fn(toml) { + toml + |> dynamic.from + |> dynamic.dict(of: dynamic.string, to: dynamic.dynamic) + }), ) dict diff --git a/src/rad/util.gleam b/src/rad/util.gleam index 8935853..e03b28e 100644 --- a/src/rad/util.gleam +++ b/src/rad/util.gleam @@ -405,8 +405,11 @@ pub fn relay_flags(flags: flag.Map) -> List(String) { get_fun: fn(Flag) -> snag.Result(List(a)), string_fun, ) { - list.map(_, with: string_fun) - |> function.compose(string.join(_, with: ",")) + fn(flags) { + flags + |> list.map(with: string_fun) + |> string.join(with: ",") + } |> relay_flag(get_fun, _) } @@ -474,7 +477,7 @@ const test_flag = "rad-test" /// pub fn quiet_or_print(input: CommandInput) -> fn(String) -> Nil { case is_test(input) { - True -> function.constant(Nil) + True -> fn(_) { Nil } False -> io.print } } @@ -487,7 +490,7 @@ pub fn quiet_or_print(input: CommandInput) -> fn(String) -> Nil { /// pub fn quiet_or_println(input: CommandInput) -> fn(String) -> Nil { case is_test(input) { - True -> function.constant(Nil) + True -> fn(_) { Nil } False -> io.println } } diff --git a/src/rad/workbook.gleam b/src/rad/workbook.gleam index 1359dd9..2cd4703 100644 --- a/src/rad/workbook.gleam +++ b/src/rad/workbook.gleam @@ -344,14 +344,14 @@ pub fn info(config: Toml) -> Result { let version = ["version"] |> toml.decode(from: config, expect: dynamic.string) - |> result.map( - with: string.append(to: "v", suffix: _) - |> function.compose(shellout.style( - _, + |> result.map(with: fn(version) { + version + |> string.append(to: "v") + |> shellout.style( with: shellout.display(["italic"]), custom: util.lookups, - )), - ) + ) + }) |> option.from_result let description = diff --git a/src/rad/workbook/standard.gleam b/src/rad/workbook/standard.gleam index 2fbbcb5..4035524 100644 --- a/src/rad/workbook/standard.gleam +++ b/src/rad/workbook/standard.gleam @@ -20,7 +20,6 @@ import gleam import gleam/dict import gleam/dynamic -import gleam/function import gleam/http.{type Header} import gleam/int import gleam/io @@ -750,10 +749,11 @@ pub fn ping(input: CommandInput, _task: Task(Result)) -> Result { |> uri.to_string |> do_ping([#("cache-control", "no-cache, no-store")]) |> result.map(with: int.to_string) - |> result.map_error( - with: int.to_string - |> function.compose(snag.new), - ) + |> result.map_error(with: fn(status) { + status + |> int.to_string + |> snag.new + }) } @target(erlang) @@ -1028,12 +1028,11 @@ pub fn tree(_input: CommandInput, _task: Task(Result)) -> Result { |> shellout.command(run: "tree", in: ".", opt: []) |> result.replace_error(snag.layer(error, "command `tree` not found")) } - |> result.map_error( - with: function.compose( - snag.layer(_, "failed to find a known tree command"), - snag.layer(_, "failed to run task"), - ), - ) + |> result.map_error(with: fn(snag) { + snag + |> snag.layer("failed to find a known tree command") + |> snag.layer("failed to run task") + }) } /// Prints stylized versions for packages found in your project's `gleam.toml` @@ -1214,12 +1213,11 @@ fn do_watch(input: CommandInput) -> Result { "command `inotifywait` not found", )) } - |> result.map_error( - with: function.compose( - snag.layer(_, "failed to find a known watcher command"), - snag.layer(_, "failed to run task"), - ), - ) + |> result.map_error(with: fn(snag) { + snag + |> snag.layer("failed to find a known watcher command") + |> snag.layer("failed to run task") + }) } @target(javascript) diff --git a/test/rad/task_test.gleam b/test/rad/task_test.gleam index c1e5b6a..8f67842 100644 --- a/test/rad/task_test.gleam +++ b/test/rad/task_test.gleam @@ -1,6 +1,5 @@ import gleam/dict import gleam/dynamic -import gleam/function import gleam/int import gleam/list import gleam/result @@ -433,11 +432,11 @@ pub fn trainer_test() { |> task.new(run: fn(input, _task) { input.args |> list.map(with: fn(arg) { - let not_oddish = + let not_oddish = fn(_) { ["not", arg] |> string.join(with: " ") |> snag.new - |> function.constant + } use maybe_oddish <- result.try( arg |> int.parse