diff --git a/CHANGELOG.md b/CHANGELOG.md index ab624f9..eff18fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ # v1 +## [1.2.0](https://github.com/TanklesXL/glint/compare/v1.2.0...v1.1.1) + ## [1.1.1](https://github.com/TanklesXL/glint/compare/v1.1.1...v1.1.0) - updated gleam stdlib to >= 0.43 diff --git a/gleam.toml b/gleam.toml index cb15824..3e7eae0 100644 --- a/gleam.toml +++ b/gleam.toml @@ -1,5 +1,5 @@ name = "glint" -version = "1.1.1" +version = "1.2.0" # Fill out these fields if you intend to generate HTML documentation or publishname = "glint" # your project to the Hex package manager. diff --git a/src/glint.gleam b/src/glint.gleam index d14721f..41cae50 100644 --- a/src/glint.gleam +++ b/src/glint.gleam @@ -315,6 +315,20 @@ pub fn command(do runner: Runner(a)) -> Command(a) { ) } +/// Map the output of a [`Command`](#Command) +/// +/// This function can be useful when you are handling user-defined commands or commands from other packages and need to make sure the return type matches your own commands. +/// +pub fn map_command(command: Command(a), with fun: fn(a) -> b) -> Command(b) { + Command( + do: fn(named_args, args, flags) { fun(command.do(named_args, args, flags)) }, + description: command.description, + flags: command.flags, + named_args: command.named_args, + unnamed_args: command.unnamed_args, + ) +} + /// Attach a helptext description to a [`Command(a)`](#Command) /// /// This function allows for user-supplied newlines in long text strings. Individual newline characters are instead converted to spaces.