Skip to content

Commit

Permalink
gleam 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TanklesXL committed Mar 5, 2024
1 parent 2eaa8d7 commit fe906f8
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 57 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
erlang: ["26.2.2"]
gleam: ["1.0.0-rc2"]
erlang: ["~> 26.2"]
gleam: ["~> 1.0"]
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/checkout@v2
- uses: ./.github/actions/test
with:
gleam-version: "1.0.0-rc2"
gleam-version: "~> 1.0"
- name: publish to hex
env:
HEXPM_USER: ${{ secrets.HEXPM_USER }}
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog

## [Unreleased](https://github.com/TanklesXL/glint/compare/v0.15.0...HEAD)
## [Unreleased](https://github.com/TanklesXL/glint/compare/v0.17.0...HEAD)

## [0.17.0](https://github.com/TanklesXL/glint/compare/v0.16.0...v0.17.0)

- support gleam 1.0.0

## [0.16.0](https://github.com/TanklesXL/glint/compare/v0.15.0...v0.16.0)

Expand Down
6 changes: 3 additions & 3 deletions gleam.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "glint"
version = "0.16.0"
version = "0.17.0"

# Fill out these fields if you intend to generate HTML documentation or publishname = "glint"
# your project to the Hex package manager.
Expand All @@ -11,10 +11,10 @@ links = [
{ title = "Hex", href = "https://hex.pm/packages/glint" },
{ title = "Docs", href = "https://hexdocs.pm/glint/" },
]
gleam = "~> 0.34 or ~> 1.0"
gleam = "~> 1.0"

[dependencies]
gleam_stdlib = "~> 0.34 or ~> 1.0"
gleam_stdlib = "~> 0.36.0 or ~> 1.0"
snag = "~> 0.2"
gleam_community_ansi = "~> 1.0"
gleam_community_colour = "~> 1.0"
Expand Down
4 changes: 2 additions & 2 deletions manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
packages = [
{ 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" },
{ name = "gleam_community_colour", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "A49A5E3AE8B637A5ACBA80ECB9B1AFE89FD3D5351FF6410A42B84F666D40D7D5" },
{ 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 = "snag", version = "0.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "snag", source = "hex", outer_checksum = "54D32E16E33655346AA3E66CBA7E191DE0A8793D2C05284E3EFB90AD2CE92BCC" },
]

[requirements]
gleam_community_ansi = { version = "~> 1.0" }
gleam_community_colour = { version = "~> 1.0" }
gleam_stdlib = { version = "~> 0.34 or ~> 1.0" }
gleam_stdlib = { version = "~> 0.36.0 or ~> 1.0" }
gleeunit = { version = "~> 1.0" }
snag = { version = "~> 0.2" }
25 changes: 12 additions & 13 deletions src/glint.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,7 @@ fn do_execute(
case args {
// when there are no more available arguments
// and help flag has been passed, generate help message
[] if help
->
[] if help ->
command_path
|> cmd_help(cmd, config, global_flags)
|> Help
Expand Down Expand Up @@ -444,12 +443,12 @@ fn execute_root(
False ->
snag.error(
"unmatched named arguments: "
<> {
contents.named_args
|> list.drop(list.length(named))
|> list.map(fn(s) { "'" <> s <> "'" })
|> string.join(", ")
},
<> {
contents.named_args
|> list.drop(list.length(named))
|> list.map(fn(s) { "'" <> s <> "'" })
|> string.join(", ")
},
)
}
})
Expand Down Expand Up @@ -479,8 +478,8 @@ fn execute_root(
Error(#(snag, help)) ->
Error(
snag.pretty_print(snag)
<> "\nSee the following help text, available via the '--help' flag.\n\n"
<> help,
<> "\nSee the following help text, available via the '--help' flag.\n\n"
<> help,
)
}
}
Expand All @@ -490,7 +489,7 @@ fn execute_root(
/// If you would like to do something with the command output please see the run_and_handle function.
///
pub fn run(from glint: Glint(a), for args: List(String)) -> Nil {
run_and_handle(from: glint, for: args, with: function.constant(Nil))
run_and_handle(from: glint, for: args, with: fn(_) { Nil })
}

/// A wrapper for `execute` that prints any errors enountered or the help text if requested.
Expand Down Expand Up @@ -678,8 +677,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
]
Expand Down
70 changes: 35 additions & 35 deletions test/glint_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -96,39 +96,39 @@ pub fn runner_test() {
}

pub fn help_test() {
let nil = function.constant(Nil)
let nil = fn(_) { Nil }
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 =
Expand All @@ -139,43 +139,43 @@ 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.unnamed_args(glint.MinArgs(2))
|> glint.named_args(["woo"]),
|> glint.flag(flag_3.0, flag_3.1)
|> glint.description("This is cmd3")
|> glint.unnamed_args(glint.MinArgs(2))
|> glint.named_args(["woo"]),
)
|> glint.add(
at: ["cmd1", "cmd4"],
do: glint.command(nil)
|> glint.flag(flag_4.0, flag_4.1)
|> glint.description("This is cmd4")
|> glint.unnamed_args(glint.EqArgs(0)),
|> glint.flag(flag_4.0, flag_4.1)
|> glint.description("This is cmd4")
|> glint.unnamed_args(glint.EqArgs(0)),
)
|> glint.add(
at: ["cmd2"],
do: glint.command(nil)
|> glint.named_args(["arg1", "arg2"])
|> glint.description("This is cmd2")
|> glint.unnamed_args(glint.EqArgs(0)),
|> glint.named_args(["arg1", "arg2"])
|> glint.description("This is cmd2")
|> glint.unnamed_args(glint.EqArgs(0)),
)
|> glint.add(
at: ["cmd5", "cmd6"],
do: glint.command(nil)
|> glint.description("This is cmd6"),
|> glint.description("This is cmd6"),
)

// execute root command
Expand Down Expand Up @@ -299,8 +299,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(
[],
Expand All @@ -312,15 +312,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
Expand Down

0 comments on commit fe906f8

Please sign in to comment.