philiprehberger-cli_kit 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 895e4a8ff9edcfa13591e60cd91454c81840404c61b724e3394d234b71f8e496
4
- data.tar.gz: b789d3b41ab39145500841661603728c8edccc438ab577319c6166bdf27230cb
3
+ metadata.gz: eae06fcc20ac2c4b561e9344b149ce324226182696988a8a80409dd21b95fb13
4
+ data.tar.gz: 1f3717ee7a4fd6a60f3ba3df8f716538c8c7300deb2d3f7f54085a1d87e8c4c8
5
5
  SHA512:
6
- metadata.gz: 6b708dc9eadf82852b3d683f32dd4adeeaae2bc0f3985ce2c338930a58cc1cb8bbe2cff17a929578907ffe68ae1c63a38ff115129fefdb68a531a18c467d0650
7
- data.tar.gz: 94e8d68950132d59d2ed894d356374269989d5f73db2837897f957cc3fd70011f5f1b4c96f8ba75554b7069c65900c1385bf357885ba925346009da154ba011f
6
+ metadata.gz: da8187a4ef2b10558b7d1950318da743851f60423580550c001dc61059a579fccedcca8a29161d2252b2a242fd61d7f8877fee666ed57e0cc6f73a97398b56fe
7
+ data.tar.gz: 4ef31ad27f1536ba102f013cad027d0d38597a5e3f6492307f2ff0a328d63de572cf42476c63e33cb73d44cb72ddc0182c8b8e9afafe706507114bb970c33d04
data/CHANGELOG.md CHANGED
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.6.0] - 2026-05-02
11
+
12
+ ### Added
13
+ - `CliKit.strip_color(text)` (and `Colorize.strip(text)`) to remove ANSI escape sequences from a string — useful for testing colored output and writing colored messages to log files
14
+
10
15
  ## [0.5.0] - 2026-04-25
11
16
 
12
17
  ### Added
data/README.md CHANGED
@@ -186,6 +186,10 @@ require "philiprehberger/cli_kit"
186
186
 
187
187
  puts Philiprehberger::CliKit.color('OK', :green)
188
188
  puts Philiprehberger::CliKit.bold('Important')
189
+
190
+ # Strip ANSI escapes (useful for tests or logging colored output to a file)
191
+ colored = Philiprehberger::CliKit.color('OK', :green)
192
+ Philiprehberger::CliKit.strip_color(colored) # => 'OK'
189
193
  ```
190
194
 
191
195
  ## API
@@ -203,6 +207,7 @@ puts Philiprehberger::CliKit.bold('Important')
203
207
  | `.color(text, name)` | Wrap text in ANSI color (no-op when not a TTY or NO_COLOR set) |
204
208
  | `.bold(text)` | Wrap text in ANSI bold |
205
209
  | `.dim(text)` | Wrap text in ANSI dim |
210
+ | `.strip_color(text)` | Remove ANSI escape sequences from text |
206
211
  | `Parser#option(name, multi: true)` | Collect repeated option values into an array |
207
212
  | `Parser#option(name, required: true)` | Raise `CliKit::Error` at parse time when the option is omitted |
208
213
  | `Parser#flags` | Hash of boolean flag values |
@@ -47,6 +47,18 @@ module Philiprehberger
47
47
 
48
48
  "\e[2m#{text}\e[0m"
49
49
  end
50
+
51
+ # Remove ANSI escape sequences (color, bold, dim, reset, etc.) from text.
52
+ # Idempotent on already-plain strings. Returns text unchanged when input
53
+ # is not a String (e.g. nil → nil).
54
+ #
55
+ # @param text [String, Object]
56
+ # @return [String, Object]
57
+ def strip(text)
58
+ return text unless text.is_a?(String)
59
+
60
+ text.gsub(/\e\[[0-9;]*m/, '')
61
+ end
50
62
  end
51
63
  end
52
64
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Philiprehberger
4
4
  module CliKit
5
- VERSION = '0.5.0'
5
+ VERSION = '0.6.0'
6
6
  end
7
7
  end
@@ -127,5 +127,14 @@ module Philiprehberger
127
127
  def self.dim(text)
128
128
  Colorize.dim(text)
129
129
  end
130
+
131
+ # Remove ANSI escape sequences from text. Useful for testing colored output
132
+ # or for logging colored messages without escape codes leaking through.
133
+ #
134
+ # @param text [String]
135
+ # @return [String]
136
+ def self.strip_color(text)
137
+ Colorize.strip(text)
138
+ end
130
139
  end
131
140
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: philiprehberger-cli_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Rehberger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-26 00:00:00.000000000 Z
11
+ date: 2026-05-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Lightweight CLI toolkit combining argument parsing with flags and options,
14
14
  interactive prompts with confirmation, and animated spinners for long-running operations.