Skip to content
/ chuf Public

a command line utility that transforms stdin to stdout by sending user defined chunks through the specified filter

License

Notifications You must be signed in to change notification settings

lenzj/chuf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chuf

chuf is a command line utility that transforms stdin to stdout by sending predefined chunks through the specified FILTER. A chunk is defined by a BEGIN and END byte sequence within the stream. Anything not within a chunk is passed along unmodified.

Synopsis

chuf BEGIN END FILTER

BEGIN : Byte sequence designating beginning of chunk

END : Byte sequence designating end of chunk

FILTER : Command filter to transform chunk. A multiple parameter command filter must be enclosed in quotes.

Example 1 - Simple text markup using unix "tr" command.

$ echo "the quick {U}brown fox{R} jumped over the lazy dog" | \\
chuf {U} {R} "tr [:lower:] [:upper:]"
the quick BROWN FOX jumped over the lazy dog

Example 2 - Expand markdown within html document.

$ cat example.mdhtml
<!DOCTYPE html>
<html>
    <head>
        <title>Example</title>
    </head>
    <body>
<md>
# Markdown table example

| Name   | Hobby        | Age   |
| ------ |:------------:| -----:|
| Bob    | golfing      |    18 |
| Monica | programming  |    32 |
</md>
    </body>
</html>
$ chuf '<md>' '</md>' markdown < example.mdhtml
<!DOCTYPE html>
<html>
    <head>
        <title>Example</title>
    </head>
    <body>
<h1>Markdown table example</h1>
<table>
<thead>
<tr>
<th> Name   </th>
<th style="text-align:center;"> Hobby        </th>
<th style="text-align:right;"> Age   </th>
</tr>
</thead>
<tbody>
<tr>
<td> Bob    </td>
<td style="text-align:center;"> golfing      </td>
<td style="text-align:right;">    18 </td>
</tr>
<tr>
<td> Monica </td>
<td style="text-align:center;"> programming  </td>
<td style="text-align:right;">    32 </td>
</tr>
</tbody>
</table>
    </body>
</html>

Compiling from source

Dependencies

  • Go compiler (v1.12 or later).
  • Go package chunkio
  • Go package testcli to run tests.
  • scdoc utility to generate the man page. Only needed if changes to man page source (chuf.1.scd) are made.
  • pgot utility to process files in the templates sub folder. Only needed if changes to README.md, LICENCE, Makefile etc. are needed.

Installing

$ make
# make install

Running the tests

$ make check

Contributing

If you have a bugfix, update, issue or feature enhancement the best way to reach me is by following the instructions in the link below. Thank you!

https://blog.lenzplace.org/contact

Versioning

I follow the SemVer strategy for versioning. The latest version is listed in the releases section.

License

This project is licensed under a BSD two clause license - see the LICENSE file for details.

About

a command line utility that transforms stdin to stdout by sending user defined chunks through the specified filter

Resources

License

Stars

Watchers

Forks

Packages