Skip to content

Commit

Permalink
v0.18.1
Browse files Browse the repository at this point in the history
  • Loading branch information
TanklesXL committed Apr 21, 2024
1 parent 9c51911 commit 38c26e6
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 100 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

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

## [0.18.1](https://github.com/TanklesXL/glint/compare/v0.18.0...v0.18.1)

- relax gleam stdlib version constraint

## [0.18.0](https://github.com/TanklesXL/glint/compare/v0.17.1...v0.18.0)

- support for group flags at a given path
Expand Down
6 changes: 4 additions & 2 deletions examples/hello/src/hello.gleam
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
// stdlib imports
import gleam/dict
import gleam/io
import gleam/list
import gleam/string.{uppercase}
import gleam/dict

// external dep imports
import snag

// glint imports
import argv
import glint
import glint/flag
import argv

// ----- APPLICATION LOGIC -----

Expand Down
2 changes: 1 addition & 1 deletion examples/hello/test/hello_test.gleam
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import gleam/list
import gleeunit
import gleeunit/should
import hello
import gleam/list

pub fn main() {
gleeunit.main()
Expand Down
4 changes: 2 additions & 2 deletions gleam.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "glint"
version = "0.18.0"
version = "0.18.1"

# Fill out these fields if you intend to generate HTML documentation or publishname = "glint"
# your project to the Hex package manager.
Expand All @@ -14,7 +14,7 @@ links = [
gleam = "~> 1.0"

[dependencies]
gleam_stdlib = "~> 0.36.0 or ~> 1.0"
gleam_stdlib = "~> 0.36 or ~> 1.0"
snag = "~> 0.2"
gleam_community_ansi = "~> 1.0"
gleam_community_colour = "~> 1.0"
Expand Down
10 changes: 6 additions & 4 deletions manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@

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.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 = "gleam_community_colour", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_json", "gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "795964217EBEDB3DA656F5EB8F67D7AD22872EB95182042D3E7AFEF32D3FD2FE" },
{ 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.37.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "5398BD6C2ABA17338F676F42F404B9B7BABE1C8DC7380031ACB05BBE1BCF3742" },
{ name = "gleeunit", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "72CDC3D3F719478F26C4E2C5FED3E657AC81EC14A47D2D2DEBB8693CA3220C3B" },
{ 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" },
]

[requirements]
gleam_community_ansi = { version = "~> 1.0" }
gleam_community_colour = { version = "~> 1.0" }
gleam_stdlib = { version = "~> 0.36.0 or ~> 1.0" }
gleam_stdlib = { version = "~> 0.36 or ~> 1.0" }
gleeunit = { version = "~> 1.0" }
snag = { version = "~> 0.2" }
18 changes: 9 additions & 9 deletions src/glint.gleam
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import gleam
import gleam/bool
import gleam/dict
import gleam/option.{type Option, None, Some}
import gleam/list
import gleam/io
import gleam/int
import gleam/io
import gleam/list
import gleam/option.{type Option, None, Some}
import gleam/result
import gleam/string
import snag.{type Result}
import glint/flag.{type Flag, type Map as FlagMap}
import gleam/string_builder as sb
import gleam_community/ansi
import gleam_community/colour.{type Colour}
import gleam/result
import gleam
import glint/flag.{type Flag, type Map as FlagMap}
import snag.{type Result}

// --- CONFIGURATION ---

Expand Down Expand Up @@ -182,8 +182,8 @@ pub fn add(
Glint(
..glint,
cmd: path
|> sanitize_path
|> do_add(to: glint.cmd, put: contents),
|> sanitize_path
|> do_add(to: glint.cmd, put: contents),
)
}

Expand Down
10 changes: 5 additions & 5 deletions src/glint/flag.gleam
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import gleam
import gleam/dict
import gleam/string
import gleam/result
import gleam/float
import gleam/int
import gleam/list
import gleam/float
import snag.{type Result, type Snag}
import gleam/option.{type Option, None, Some}
import gleam/result
import gleam/string
import glint/flag/constraint.{type Constraint}
import gleam
import snag.{type Result, type Snag}

/// Flag inputs must start with this prefix
///
Expand Down
2 changes: 1 addition & 1 deletion src/glint/flag/constraint.gleam
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import gleam/list
import gleam/result
import gleam/string
import gleam/set
import gleam/string
import snag.{type Result}

/// Constraint type for verifying flag values
Expand Down
52 changes: 26 additions & 26 deletions test/glint/flag/contraint_test.gleam
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import glint/flag/constraint.{each, none_of, one_of}
import gleam/list
import gleeunit/should
import glint/flag
import gleam/list
import glint/flag/constraint.{each, none_of, one_of}

pub fn one_of_test() {
1
Expand Down Expand Up @@ -70,15 +70,15 @@ pub fn flag_one_of_none_of_test() {
"li",
flag.int_list()
|> flag.constraint(
[1, 2, 3]
|> one_of
|> each,
)
[1, 2, 3]
|> one_of
|> each,
)
|> flag.constraint(
[4, 5, 6]
|> none_of
|> each,
)
[4, 5, 6]
|> none_of
|> each,
)
|> flag.build,
"1,1,1",
"2,2,6",
Expand All @@ -96,15 +96,15 @@ pub fn flag_one_of_none_of_test() {
"lf",
flag.float_list()
|> flag.constraint(
[1.0, 2.0, 3.0]
|> one_of()
|> each,
)
[1.0, 2.0, 3.0]
|> one_of()
|> each,
)
|> flag.constraint(
[4.0, 5.0, 6.0]
|> none_of()
|> each,
)
[4.0, 5.0, 6.0]
|> none_of()
|> each,
)
|> flag.build,
"3.0,2.0,1.0",
"2.0,3.0,6.0",
Expand All @@ -122,15 +122,15 @@ pub fn flag_one_of_none_of_test() {
"ls",
flag.string_list()
|> flag.constraint(
["t1", "t2", "t3"]
|> one_of
|> each,
)
["t1", "t2", "t3"]
|> one_of
|> each,
)
|> flag.constraint(
["t4", "t5", "t6"]
|> none_of
|> each,
)
["t4", "t5", "t6"]
|> none_of
|> each,
)
|> flag.build,
"t3,t2,t1",
"t2,t4,t1",
Expand Down
68 changes: 34 additions & 34 deletions test/glint/flag_test.gleam
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import gleam/dict as map
import gleeunit/should
import glint.{type CommandInput}
import glint/flag
import gleam/dict as map

pub fn update_flag_test() {
let flags =
Expand Down Expand Up @@ -106,12 +106,12 @@ pub fn flag_default_test() {
|> 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)))
})
in.flags
|> map.get(flag.0)
|> should.equal(Ok(flag.build(flag.1)))
})
|> glint.flag_tuple(flag),
)
|> glint.execute(["cmd", ..args])
Expand Down Expand Up @@ -338,10 +338,10 @@ pub fn global_flag_test() {
at: [],
do: glint.command(testcase([1.0, 2.0]))
|> glint.flag(
"flag",
flag.float_list()
|> flag.default([1.0, 2.0]),
),
"flag",
flag.float_list()
|> flag.default([1.0, 2.0]),
),
)
|> glint.execute([])
|> should.be_ok()
Expand All @@ -357,10 +357,10 @@ pub fn global_flag_test() {
at: [],
do: glint.command(testcase([5.0, 6.0]))
|> glint.flag(
"flag",
flag.float_list()
|> flag.default([1.0, 2.0]),
),
"flag",
flag.float_list()
|> flag.default([1.0, 2.0]),
),
)
|> glint.execute(["--flag=5.0,6.0"])
|> should.be_ok()
Expand All @@ -385,10 +385,10 @@ pub fn toggle_test() {
|> glint.add(
[],
glint.command(fn(in: CommandInput) {
in.flags
|> flag.get_bool(for: "flag")
|> should.equal(Ok(True))
})
in.flags
|> flag.get_bool(for: "flag")
|> should.equal(Ok(True))
})
|> glint.flag("flag", flag.bool()),
)
|> glint.execute([flag_input])
Expand All @@ -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))
})
in.flags
|> flag.get_bool(for: "flag")
|> should.equal(Ok(False))
})
|> glint.flag(
"flag",
flag.bool()
|> flag.default(True),
),
"flag",
flag.bool()
|> flag.default(True),
),
)
|> glint.execute([flag_input])
|> should.be_ok()
Expand All @@ -419,10 +419,10 @@ pub fn toggle_test() {
|> glint.add(
[],
glint.command(fn(in: CommandInput) {
in.flags
|> flag.get_bool(for: "flag")
|> should.equal(Ok(True))
})
in.flags
|> flag.get_bool(for: "flag")
|> should.equal(Ok(True))
})
|> glint.flag("flag", flag.bool()),
)
|> glint.execute([flag_input])
Expand All @@ -434,10 +434,10 @@ pub fn toggle_test() {
[],
glint.command(fn(_) { Nil })
|> glint.flag(
"flag",
flag.int()
|> flag.default(1),
),
"flag",
flag.int()
|> flag.default(1),
),
)
|> glint.execute([flag_input])
|> should.be_error()
Expand Down
32 changes: 16 additions & 16 deletions test/glint_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,15 @@ pub fn global_and_group_flags_test() {
|> glint.add(
["sub"],
glint.command(fn(ctx) {
flag.get_bool(ctx.flags, "f")
|> should.equal(Ok(True))
})
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"),
),
"f",
flag.bool()
|> flag.default(True)
|> flag.description("i decided to override the global flag"),
),
)
|> glint.group_flag(
["sub"],
Expand All @@ -330,15 +330,15 @@ pub fn global_and_group_flags_test() {
|> glint.add(
["sub", "sub"],
glint.command(fn(ctx) {
flag.get_int(ctx.flags, "sub_group_flag")
|> should.equal(Ok(2))
})
flag.get_int(ctx.flags, "sub_group_flag")
|> should.equal(Ok(2))
})
|> glint.flag(
"f",
flag.bool()
|> flag.default(True)
|> flag.description("i decided to override the global 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 38c26e6

Please sign in to comment.