Skip to content

Commit

Permalink
add the glint.map_command function
Browse files Browse the repository at this point in the history
  • Loading branch information
TanklesXL committed Dec 28, 2024
1 parent 1205fbd commit 8eedcbb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gleam.toml
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
14 changes: 14 additions & 0 deletions src/glint.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 8eedcbb

Please sign in to comment.