PaSteboard String Tranform tool - Haskell edition.
There are two ways to get data into this tool, cat
something to it, or just run it and it will take the value in your pasteboard.
There are a lot of tools for transforming strings on the CLI, but the most useful tool is the one you remember how to use. This tool aims to be useful, but unsurprising in behavior.
- This utility transforms strings with a typed dsl.
- The syntax is inspired by Julialang's pipeline operator
|>
- This utility was born as a reimplentation of daniel-beard/psst with the following:
- Less syntax (for now), 'command' based
- Better documentation
- A typed representation
- Fast start time (Julia takes a while to warm up)
- Easy to add new commands
- Better error messages
- Interpreted, with ability to output partial results in case of errors
echo 'hello world' | psst-hs 'words |> uppercase |> take(2) |> base64 |> unbase64'
["HE","WO"]
There are currently only a few types in psst-hs
:
- VString
- VStringList
- VInt
- VBool
- VError
Many commands work the same across VString
and VStringList
types. The function used in the VString
type is just mapped across the list.
Commands are chained by the pipeline operator |>
. Each command opts in to a particular input type.
base64 -> VString
- Description: Base64 encoding of a VString
- Example:
echo 'hello world' | psst-hs 'base64'
> aGVsbG8gd29ybGQK
head -> VString
- Description: Take the first value
- Example:
echo 'hello world' | psst-hs 'head'
> h
length -> VInt
- Description: Return a
VInt
representing the length of aVString
- Example:
echo 'hi' | psst-hs 'length'
> 2
lowercase -> VString
- Description: Return a
VString
with all characters set to lowercase - Example:
echo 'HELLO WORLD' | psst-hs 'lowercase'
> "hello world"
match -> VStringList
- Description: Return all matches for a given regex
- Example:
echo 'hello world' | psst-hs 'match("[a-z]+")'
["hello", "world"]
matches -> VBool
- Description: Return a
VBool
indicating if input matches a regex - Example:
echo "hello world" | psst-hs 'matches("\\w+")'
True
reverse -> VStringList
- Description: Return a
VString
with the characters reversed from their original order - Example:
echo 'hello world' | psst-hs 'reverse'
> dlrow olleh
tail -> VString
- Description: All characters except the first one. Returns a
VString
- Example:
echo 'hello world' | psst-hs 'tail'
> ello world
take(Int) -> VString
- Description: Output only the prefix number of characters. Returns a
VString
- Example:
echo 'hello world' | psst-hs 'take(4)'
> hell
unbase64 -> VString
- Description: Decode a base64 representation. Returns a
VString
. - Example:
echo 'aGVsbG8gd29ybGQK' | psst-hs 'unbase64'
> hello world
uppercase -> VString
- Description: Uppercase the string. Returns a
VString
- Example:
echo 'hello world' | psst-hs 'uppercase'
> HELLO WORLD
words -> VStringList
- Description: Split a
VString
into components separated by whitespace. Returns aVStringList
- Example:
echo 'hello world' | psst-hs 'words'
> ["hello", "world"]
base64 -> VStringList
- Description: Maps the
VString
method across aVStringList
- Example:
echo 'hello world' | psst-hs 'words |> base64'
> ["aGVsbG8=","d29ybGQ="]
length -> VInt
- Description: Returns the length of the
VStringList
asVInt
- Example:
echo 'hello world' | psst-hs 'words |> length'
> 2
lowercase -> VStringList
- Description: Maps the
VString
method across aVStringList
- Example:
echo 'HELLO WORLD' | psst-hs 'words |> lowercase'
> ["hello", "world"]
reverse -> VStringList
- Description: Reverse the order of elements within the
VStringList
- Example:
echo 'hello world' | psst-hs 'words |> reverse'
> ["world", "hello"]
unbase64 -> VStringList
- Description: Maps the
VString
method across aVStringList
- Example:
echo 'aGVsbG8= d29ybGQ=' | psst-hs 'words |> unbase64'
> ["hello", "world"]
uppercase -> VStringList
- Description: Maps the
VString
method across aVStringList
- Example:
echo 'hello world' | psst-hs 'words |> uppercase'
> ["HELLO", "WORLD"]
tail -> VString
- Description: Returns the last
VString
from aVStringList
- Example:
echo 'hello world' | psst-hs 'words |> tail'
> ["WORLD"]
take(VInt) -> VStringList
- Description: Returns the first n
VString
values from aVStringList
- Example:
echo '1 2 3 4 5' | psst-hs 'words |> take(4)'
> ["1", "2", "3", "4"]
brew install pcre
# For M1s
brew list pcre | grep 'pcre\.h$'
/opt/homebrew/include
ln -s /usr/local/pcre-8.45 /usr/sbin/pcre
ln -s /usr/local/pcre-8.45/include/pcre.h /usr/include/pcre.h