diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml index 84db130..69b1ca4 100644 --- a/.github/actions/test/action.yml +++ b/.github/actions/test/action.yml @@ -9,7 +9,7 @@ inputs: erlang-version: description: erlang-otp version required: false - default: 25.0.2 + default: 26.2.2 node-version: description: nodeJS version required: false diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 24d55cc..081d467 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,8 +7,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - erlang: ["25.3.2.3", "26.0.2"] - gleam: ["0.34.1"] + erlang: ["25.3.2.3", "26.2.2"] + gleam: ["0.34.1","1.0.0-rc1"] steps: - uses: actions/checkout@v2 - uses: ./.github/actions/test diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 770b174..7c9f91d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v2 - uses: ./.github/actions/test with: - gleam-version: "0.34.1" + gleam-version: "1.0.0-rc1" - name: publish to hex env: HEXPM_USER: ${{ secrets.HEXPM_USER }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 143bc91..d2e3f69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## [Unreleased](https://github.com/TanklesXL/glint/compare/v0.14.0...HEAD) +## [0.15.0-rc1](https://github.com/TanklesXL/glint/compare/v0.14.0...v0.15.0-rc1) +- support gleam >=0.34 or 1.0.x + ## [0.15.0-rc1](https://github.com/TanklesXL/glint/compare/v0.14.0...v0.15.0-rc1) - refactor of help generation logic, no change to help text output diff --git a/gleam.toml b/gleam.toml index fd5d6f7..33e1ab6 100644 --- a/gleam.toml +++ b/gleam.toml @@ -11,7 +11,7 @@ links = [ { title = "Hex", href = "https://hex.pm/packages/glint" }, { title = "Docs", href = "https://hexdocs.pm/glint/" }, ] -gleam = ">= 0.33.0" +gleam = ">=0.34.1 or ~> 1.0" [dependencies] gleam_stdlib = "~> 0.19" diff --git a/src/glint.gleam b/src/glint.gleam index a5c5f3e..9e1e780 100644 --- a/src/glint.gleam +++ b/src/glint.gleam @@ -652,8 +652,8 @@ fn build_subcommands_help( Metadata( name: name, description: cmd.contents - |> option.map(fn(command) { command.description }) - |> option.unwrap(""), + |> option.map(fn(command) { command.description }) + |> option.unwrap(""), ), ..acc ] diff --git a/src/glint/flag/constraint.gleam b/src/glint/flag/constraint.gleam index 91e370a..0130d7d 100644 --- a/src/glint/flag/constraint.gleam +++ b/src/glint/flag/constraint.gleam @@ -20,14 +20,14 @@ pub fn one_of(allowed: List(a)) -> Constraint(a) { False -> snag.error( "invalid value '" - <> string.inspect(val) - <> "', must be one of: [" - <> { - allowed - |> list.map(fn(a) { "'" <> string.inspect(a) <> "'" }) - |> string.join(", ") - } - <> "]", + <> string.inspect(val) + <> "', must be one of: [" + <> { + allowed + |> list.map(fn(a) { "'" <> string.inspect(a) <> "'" }) + |> string.join(", ") + } + <> "]", ) } } @@ -43,16 +43,16 @@ pub fn none_of(disallowed: List(a)) -> Constraint(a) { True -> snag.error( "invalid value '" - <> string.inspect(val) - <> "', must not be one of: [" - <> { - { - disallowed - |> list.map(fn(a) { "'" <> string.inspect(a) <> "'" }) - |> string.join(", ") - <> "]" - } - }, + <> string.inspect(val) + <> "', must not be one of: [" + <> { + { + disallowed + |> list.map(fn(a) { "'" <> string.inspect(a) <> "'" }) + |> string.join(", ") + <> "]" + } + }, ) } } diff --git a/test/glint/flag/contraint_test.gleam b/test/glint/flag/contraint_test.gleam index 9de2493..bc57f13 100644 --- a/test/glint/flag/contraint_test.gleam +++ b/test/glint/flag/contraint_test.gleam @@ -60,78 +60,78 @@ pub fn flag_one_of_none_of_test() { #( "i", flag.int() - |> flag.constraint(one_of([1, 2, 3])) - |> flag.constraint(none_of([4, 5, 6])) - |> flag.build, + |> flag.constraint(one_of([1, 2, 3])) + |> flag.constraint(none_of([4, 5, 6])) + |> flag.build, "1", "6", ), #( "li", flag.int_list() - |> flag.constraint( - [1, 2, 3] - |> one_of - |> each, - ) - |> flag.constraint( - [4, 5, 6] - |> none_of - |> each, - ) - |> flag.build, + |> flag.constraint( + [1, 2, 3] + |> one_of + |> each, + ) + |> flag.constraint( + [4, 5, 6] + |> none_of + |> each, + ) + |> flag.build, "1,1,1", "2,2,6", ), #( "f", flag.float() - |> flag.constraint(one_of([1.0, 2.0, 3.0])) - |> flag.constraint(none_of([4.0, 5.0, 6.0])) - |> flag.build, + |> flag.constraint(one_of([1.0, 2.0, 3.0])) + |> flag.constraint(none_of([4.0, 5.0, 6.0])) + |> flag.build, "1.0", "6.0", ), #( "lf", flag.float_list() - |> flag.constraint( - [1.0, 2.0, 3.0] - |> one_of() - |> each, - ) - |> flag.constraint( - [4.0, 5.0, 6.0] - |> none_of() - |> each, - ) - |> flag.build, + |> flag.constraint( + [1.0, 2.0, 3.0] + |> one_of() + |> each, + ) + |> flag.constraint( + [4.0, 5.0, 6.0] + |> none_of() + |> each, + ) + |> flag.build, "3.0,2.0,1.0", "2.0,3.0,6.0", ), #( "s", flag.string() - |> flag.constraint(one_of(["t1", "t2", "t3"])) - |> flag.constraint(none_of(["t4", "t5", "t6"])) - |> flag.build, + |> flag.constraint(one_of(["t1", "t2", "t3"])) + |> flag.constraint(none_of(["t4", "t5", "t6"])) + |> flag.build, "t3", "t4", ), #( "ls", flag.string_list() - |> flag.constraint( - ["t1", "t2", "t3"] - |> one_of - |> each, - ) - |> flag.constraint( - ["t4", "t5", "t6"] - |> none_of - |> each, - ) - |> flag.build, + |> flag.constraint( + ["t1", "t2", "t3"] + |> one_of + |> each, + ) + |> flag.constraint( + ["t4", "t5", "t6"] + |> none_of + |> each, + ) + |> flag.build, "t3,t2,t1", "t2,t4,t1", ), diff --git a/test/glint/flag_test.gleam b/test/glint/flag_test.gleam index a077d48..5808b2b 100644 --- a/test/glint/flag_test.gleam +++ b/test/glint/flag_test.gleam @@ -99,20 +99,20 @@ pub fn flag_default_test() { let flag = #( "flag", flag.string() - |> flag.default("default"), + |> flag.default("default"), ) glint.new() |> glint.add( ["cmd"], glint.command(fn(in: CommandInput) { - should.equal(in.args, args) + should.equal(in.args, args) - in.flags - |> map.get(flag.0) - |> should.equal(Ok(flag.build(flag.1))) - }) - |> glint.flag_tuple(flag), + in.flags + |> map.get(flag.0) + |> should.equal(Ok(flag.build(flag.1))) + }) + |> glint.flag_tuple(flag), ) |> glint.execute(["cmd", ..args]) |> should.be_ok() @@ -134,7 +134,7 @@ pub fn flag_value_test() { |> glint.add( ["cmd"], glint.command(flag_value_should_be_set) - |> glint.flag_tuple(flag), + |> glint.flag_tuple(flag), ) |> glint.execute(["cmd", flag_input, ..args]) |> should.be_ok() @@ -149,7 +149,7 @@ pub fn int_flag_test() { |> glint.add( [], glint.command(fn(_) { Nil }) - |> glint.flag_tuple(flags), + |> glint.flag_tuple(flags), ) |> glint.execute([flag_input]) |> should.be_error() @@ -166,7 +166,7 @@ pub fn int_flag_test() { |> glint.add( [], glint.command(expect_flag_value_of_10) - |> glint.flag_tuple(flags), + |> glint.flag_tuple(flags), ) |> glint.execute([flag_input]) |> should.be_ok() @@ -181,7 +181,7 @@ pub fn bool_flag_test() { |> glint.add( [], glint.command(fn(_) { Nil }) - |> glint.flag_tuple(flag), + |> glint.flag_tuple(flag), ) |> glint.execute([flag_input]) |> should.be_error() @@ -197,7 +197,7 @@ pub fn bool_flag_test() { |> glint.add( [], glint.command(expect_flag_value_of_false) - |> glint.flag_tuple(flag), + |> glint.flag_tuple(flag), ) |> glint.execute([flag_input]) |> should.be_ok() @@ -215,7 +215,7 @@ pub fn strings_flag_test() { |> glint.add( [], glint.command(expect_flag_value_list) - |> glint.flag_tuple(flags), + |> glint.flag_tuple(flags), ) |> glint.execute([flag_input]) |> should.be_ok() @@ -230,7 +230,7 @@ pub fn ints_flag_test() { |> glint.add( [], glint.command(fn(_) { Nil }) - |> glint.flag_tuple(flag), + |> glint.flag_tuple(flag), ) |> glint.execute([flag_input]) |> should.be_error() @@ -246,7 +246,7 @@ pub fn ints_flag_test() { |> glint.add( [], glint.command(expect_flag_value_list) - |> glint.flag_tuple(flag), + |> glint.flag_tuple(flag), ) |> glint.execute([flag_input]) |> should.be_ok() @@ -261,7 +261,7 @@ pub fn float_flag_test() { |> glint.add( [], glint.command(fn(_) { Nil }) - |> glint.flag_tuple(flag), + |> glint.flag_tuple(flag), ) |> glint.execute([flag_input]) |> should.be_error() @@ -278,7 +278,7 @@ pub fn float_flag_test() { |> glint.add( [], glint.command(expect_flag_value_of_10) - |> glint.flag_tuple(flag), + |> glint.flag_tuple(flag), ) |> glint.execute([flag_input]) |> should.be_ok() @@ -293,7 +293,7 @@ pub fn floats_flag_test() { |> glint.add( [], glint.command(fn(_) { Nil }) - |> glint.flag_tuple(flag), + |> glint.flag_tuple(flag), ) |> glint.execute([flag_input]) |> should.be_error() @@ -309,7 +309,7 @@ pub fn floats_flag_test() { |> glint.add( [], glint.command(expect_flag_value_list) - |> glint.flag_tuple(flag), + |> glint.flag_tuple(flag), ) |> glint.execute([flag_input]) |> should.be_ok() @@ -337,11 +337,11 @@ pub fn global_flag_test() { |> glint.add( at: [], do: glint.command(testcase([1.0, 2.0])) - |> glint.flag( - "flag", - flag.float_list() - |> flag.default([1.0, 2.0]), - ), + |> glint.flag( + "flag", + flag.float_list() + |> flag.default([1.0, 2.0]), + ), ) |> glint.execute([]) |> should.be_ok() @@ -351,16 +351,16 @@ pub fn global_flag_test() { |> glint.global_flag( "flag", flag.float_list() - |> flag.default([3.0, 4.0]), + |> flag.default([3.0, 4.0]), ) |> glint.add( at: [], do: glint.command(testcase([5.0, 6.0])) - |> glint.flag( - "flag", - flag.float_list() - |> flag.default([1.0, 2.0]), - ), + |> glint.flag( + "flag", + flag.float_list() + |> flag.default([1.0, 2.0]), + ), ) |> glint.execute(["--flag=5.0,6.0"]) |> should.be_ok() @@ -373,7 +373,7 @@ pub fn toggle_test() { |> glint.add( [], glint.command(fn(_) { Nil }) - |> glint.flag("flag", flag.bool()), + |> glint.flag("flag", flag.bool()), ) |> glint.execute([flag_input]) |> should.be_error() @@ -385,11 +385,11 @@ pub fn toggle_test() { |> glint.add( [], glint.command(fn(in: CommandInput) { - in.flags - |> flag.get_bool(for: "flag") - |> should.equal(Ok(True)) - }) - |> glint.flag("flag", flag.bool()), + in.flags + |> flag.get_bool(for: "flag") + |> should.equal(Ok(True)) + }) + |> glint.flag("flag", flag.bool()), ) |> glint.execute([flag_input]) |> should.be_ok() @@ -401,15 +401,15 @@ pub fn toggle_test() { |> glint.add( [], glint.command(fn(in: CommandInput) { - in.flags - |> flag.get_bool(for: "flag") - |> should.equal(Ok(False)) - }) - |> glint.flag( - "flag", - flag.bool() - |> flag.default(True), - ), + in.flags + |> flag.get_bool(for: "flag") + |> should.equal(Ok(False)) + }) + |> glint.flag( + "flag", + flag.bool() + |> flag.default(True), + ), ) |> glint.execute([flag_input]) |> should.be_ok() @@ -419,11 +419,11 @@ pub fn toggle_test() { |> glint.add( [], glint.command(fn(in: CommandInput) { - in.flags - |> flag.get_bool(for: "flag") - |> should.equal(Ok(True)) - }) - |> glint.flag("flag", flag.bool()), + in.flags + |> flag.get_bool(for: "flag") + |> should.equal(Ok(True)) + }) + |> glint.flag("flag", flag.bool()), ) |> glint.execute([flag_input]) |> should.be_ok() @@ -433,11 +433,11 @@ pub fn toggle_test() { |> glint.add( [], glint.command(fn(_) { Nil }) - |> glint.flag( - "flag", - flag.int() - |> flag.default(1), - ), + |> glint.flag( + "flag", + flag.int() + |> flag.default(1), + ), ) |> glint.execute([flag_input]) |> should.be_error() diff --git a/test/glint_test.gleam b/test/glint_test.gleam index 08422cb..cda9c01 100644 --- a/test/glint_test.gleam +++ b/test/glint_test.gleam @@ -100,35 +100,35 @@ pub fn help_test() { let global_flag = #( "global", flag.string() - |> flag.description("This is a global flag"), + |> flag.description("This is a global flag"), ) let flag_1 = #( "flag1", flag.string() - |> flag.description("This is flag1"), + |> flag.description("This is flag1"), ) let flag_2 = #( "flag2", flag.int() - |> flag.description("This is flag2"), + |> flag.description("This is flag2"), ) let flag_3 = #( "flag3", flag.bool() - |> flag.description("This is flag3"), + |> flag.description("This is flag3"), ) let flag_4 = #( "flag4", flag.float() - |> flag.description("This is flag4"), + |> flag.description("This is flag4"), ) let flag_5 = #( "flag5", flag.float_list() - |> flag.description("This is flag5"), + |> flag.description("This is flag5"), ) let cli = @@ -139,40 +139,40 @@ pub fn help_test() { |> glint.add( at: [], do: glint.command(do: nil) - |> glint.named_args(["arg1", "arg2"]) - |> glint.flag(flag_1.0, flag_1.1) - |> glint.description("This is the root command"), + |> glint.named_args(["arg1", "arg2"]) + |> glint.flag(flag_1.0, flag_1.1) + |> glint.description("This is the root command"), ) |> glint.add( at: ["cmd1"], do: glint.command(nil) - |> glint.flag(flag_2.0, flag_2.1) - |> glint.flag(flag_5.0, flag_5.1) - |> glint.description("This is cmd1"), + |> glint.flag(flag_2.0, flag_2.1) + |> glint.flag(flag_5.0, flag_5.1) + |> glint.description("This is cmd1"), ) |> glint.add( at: ["cmd1", "cmd3"], do: glint.command(nil) - |> glint.flag(flag_3.0, flag_3.1) - |> glint.description("This is cmd3"), + |> glint.flag(flag_3.0, flag_3.1) + |> glint.description("This is cmd3"), ) |> glint.add( at: ["cmd1", "cmd4"], do: glint.command(nil) - |> glint.flag(flag_4.0, flag_4.1) - |> glint.description("This is cmd4"), + |> glint.flag(flag_4.0, flag_4.1) + |> glint.description("This is cmd4"), ) |> glint.add( at: ["cmd2"], do: glint.command(nil) - |> glint.named_args(["arg1", "arg2"]) - |> glint.count_args(glint.MinArgs(2)) - |> glint.description("This is cmd2"), + |> glint.named_args(["arg1", "arg2"]) + |> glint.count_args(glint.MinArgs(2)) + |> glint.description("This is cmd2"), ) |> glint.add( at: ["cmd5", "cmd6"], do: glint.command(nil) - |> glint.description("This is cmd6"), + |> glint.description("This is cmd6"), ) // execute root command @@ -266,8 +266,8 @@ pub fn global_flags_test() { |> glint.global_flag( "f", flag.int() - |> flag.default(2) - |> flag.description("global flag example"), + |> flag.default(2) + |> flag.description("global flag example"), ) |> glint.add( [], @@ -279,15 +279,15 @@ pub fn global_flags_test() { |> glint.add( ["sub"], glint.command(fn(ctx) { - flag.get_bool(ctx.flags, "f") - |> should.equal(Ok(True)) - }) - |> glint.flag( - "f", - flag.bool() - |> flag.default(True) - |> flag.description("i decided to override the global flag"), - ), + flag.get_bool(ctx.flags, "f") + |> should.equal(Ok(True)) + }) + |> glint.flag( + "f", + flag.bool() + |> flag.default(True) + |> flag.description("i decided to override the global flag"), + ), ) // root command keeps the global flag as an int