Show HN: Purl – A Simple Tool for Text Processing (github.com)
Hello HN community,
I'm excited to share a new command-line tool I developed called purl, inspired by the simplicity of Perl one-liners for efficient text processing. Purl features include Perl-like regex that simplifies text manipulation, it's cross-platform so works equally well on macOS, Linux, etc., and it's quick and easy to install. The tool also supports simple commands such as -replace, -filter, and -exclude, and offers optional color output to enhance readability.
Purl is a practical alternative to traditional tools like sed and grep, designed to address some of their common limitations.
For more information and to try purl yourself, visit: https://github.com/catatsuy/purl
I appreciate any feedback!
30 comments
[ 4.9 ms ] story [ 76.6 ms ] threadFor the old farts like me, would you consider adding in some comparisons to AWK?
Please don't use a name which is confusingly similar to an existing product (i.e. infringes on someone else's trademark). Open source communities have enough to deal with already without having to allocate scarce volunteer hours to working out legal issues.
https://www.uspto.gov/trademarks/search/likelihood-confusion
> Trademarks don’t have to be identical to be confusingly similar. Instead, they could just be similar in sound, appearance, or meaning, or could create a similar commercial impression. Here are examples of trademarks that were found to be confusingly similar.
> These trademarks are confusingly similar because they could be pronounced the same way, even though they’re spelled differently.
> Your mark -- T. Markey
> Conflicting mark -- Tee Marquee
Trademark conflicts in open store sometimes start that way. For example, “CouchBase” was a reference to “CouchDB” — it was originally a complementary effort, but later became a competitor. By the time the CouchDB folks realized that they should’ve been enforcing their trademark, it was too late.
Mostly, when there are other open source projects whose names conflict with your trademark you ask nicely and people change the name. That's the path I'm hoping to guide the OP down — please just have some sympathy for your fellow open source developers!
Occasionally, trademark conflicts in open source become high stakes, painful affairs. For example, with the last few years, there was the "Commons Clause" situation (where among other issues "Apache License Version 2 with Commons Clause" infringed upon the "Apache" trademark owned by the ASF.)
This is unlikely to become a problem with a solo personal project unless it gains sustained traction. But I think it's valid feedback to offer, because if you have ambitions for your open source project you are eventually going to have to deal with trademarks.
"can you install purl on the server so we can filter these logs?"
"do you mean the one with an e or the one with the u?"
Also, based on the name, I was half guessing this was going to be a slot in replacement to curl.
Some tools have an option to force coloured output regardless, e.g. GCC's `-fdiagnostics-color` or grep's own `--colour=always`, but apt doesn't seem to have anything like that.
In theory one could have a command in the style of nohup or stdbuf which sets up a PTY to trick the command into outputting colours. So one could run `fakepty apt search whatever | grep another` ...
> Failed to validate input: invalid replace expression format. Use "@search@replace@"
Do you plan to add the ability for it to act on files directly?
I appreciate your feedback and understand that a more flexible command structure might be easier for users. We will consider making this change in future versions to accommodate different usage preferences.
But perl allows one-liners to emulate grep (filter and exclude) and sed (replace):
Discoverability is the most important thing than other reason for me when selecting a tool.
Quoting from Purl's README:
When I use `find, xargs, cat, sed, awk, perl, like tools`, I often struggle to remember even the simplest options. What is the option for 'ignore case', 'in-place edit', or 'info'? -i could mean anything.This is one of the reasons I switched my shell to fish. It offers more discoverability than bash and zsh Fish shell supports searching for a command's options name and description using <Tab><C-s> BY DEFAULT. I believe this approach is quite effective.
Thus, I prefer Purl like syntax more.
Using single dash for single character options allows you to combine them, which is really useful (if you do remember these options of course), so `-exc` means `-e -x -c` etc.
That said, I am not convinced that making a thing easy "even for beginners" is always practical. Beginners do need to ascend some learning curves.
I make heavy use of RegEx and "one-liners" (bash-grep-awk-sed, Perl). These are powerful tools. Yes, they have strengths and weaknesses but they are built with a successful philosophy. Yes, their notation is irksome to ardent Python users who deplore all things non-Python.
The success of the RegEx model is its terse power. Something more verbose and simultaneously too simple for complex use-cases will not replace RegEx. Something that can/should do the same thing on [ $OS for $OS in @OSlist ] is a thorny problem with $OS.
As for the complex use-cases, I do not expect "beginners" to enjoy RegEx when even many otherwise talented computer users have fits of scene-stealing negativity when they encounter a regex.
Others will rightly draw attention to the need for a different project name. Naming a thing effectively is important, don't underestimate this need if you truly aim for adoption.