@asdsadw12312dwd2112xz/string-transform-cli
v1.0.0
Published
String transformation CLI tool
Downloads
70
Maintainers
Readme
string-transform-cli
A CLI tool for common string transformations. Zero external dependencies beyond commander and chalk.
Installation
npm install -g @asdsadw12312dwd2112xz/string-transform-cliUsage
string-transform <command> [text] [options]All commands accept input as a positional argument or via stdin (pipe).
reverse
Reverse a string.
string-transform reverse "hello"
# olleh
echo "hello" | string-transform reverse
# ollehcount
Character, word, and line count.
string-transform count "hello world"
# Characters: 11
# Chars (no spaces): 10
# Words: 2
# Lines: 1truncate
Truncate with ellipsis at given length.
string-transform truncate "hello world" --length 8
# hello...pad
Pad string to target length.
string-transform pad "hi" --length 10 --char "-" --side both
# ----hi----Options:
--length N(required)--char <c>(default: space)--side left|right|both(default: right)
repeat
Repeat string N times.
string-transform repeat "ab" --times 4
# ababababslug
Convert to URL-friendly slug.
string-transform slug "Hello World! Foo Bar"
# hello-world-foo-barescape
Escape special characters.
string-transform escape "<div>" --type html
# <div>
string-transform escape "a.b*c" --type regex
# a\.b\*c
string-transform escape "hello world" --type url
# hello%20worldTypes: html, regex, url
unescape
Unescape previously escaped characters.
string-transform unescape "<div>" --type html
# <div>
string-transform unescape "hello%20world" --type url
# hello worldTypes: html, url
wrap
Word wrap at given column width.
string-transform wrap "The quick brown fox jumps over the lazy dog" --width 20
# The quick brown fox
# jumps over the lazy
# dogreplace
Find and replace all occurrences.
string-transform replace "foo bar foo" --find foo --with baz
# baz bar bazLicense
MIT
