Skip to content

Commit

Permalink
Make better use of glint's new flags API
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdeviant committed Apr 21, 2024
1 parent 36e5cec commit 6cbd462
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/startest/cli.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ pub fn run(config: Config) {
|> glint.name("gleam test --")
|> glint.pretty_help(glint.default_pretty_help())
|> glint.add(at: [], do: {
use _ <- glint.flag(test_name_filter, test_name_filter_flag())
use test_name_filter <- glint.flag(
"filter",
glint.string()
|> glint.default("")
|> glint.flag_help(
"Filter down tests just to those whose names match the filter",
),
)

glint.command(fn(_named_args, args, flags) {
let filters = args

let assert Ok(filter) =
glint.get_string(from: flags, for: test_name_filter)
let assert Ok(filter) = test_name_filter(flags)

let config =
config
Expand All @@ -37,13 +43,3 @@ pub fn run(config: Config) {
})
|> glint.run(argv.load().arguments)
}

const test_name_filter = "filter"

fn test_name_filter_flag() -> glint.Flag(String) {
glint.string()
|> glint.default("")
|> glint.flag_help(
"Filter down tests just to those whose names match the filter",
)
}

0 comments on commit 6cbd462

Please sign in to comment.