Skip to main content

hr Release

I updated many projects yesterday, releasing new versions that include .deb and .rpm packaging, using docker-pkg. In doing so, I noticed that the hr project could really use an update, so I worked on that next and released version 0.3.0.1 this morning.

Library and Tests

Previously, the project only provided an executable, implemented in a single hr.hs file. It is a tiny project, so even the project Makefile was bigger than the source code! The project is still tiny, but I have now moved the core functionality into a library, separate from the CLI utility implementation. This allows unit tests to be written, as well as makes it easy to integrate the functionality into other software.

I was not sure if it is a good idea to upload the package to Hackage and Stackage… It seems silly to put such a small project into the package repository. Such practice is common in the JavaScript community, and I do not think it is good because it leads to projects having a very large number of dependencies. I decided to go ahead and do so, however, because it makes the library easier to use as well as makes the API documentation easy to browse.

I released version 0.3.0.0 with plans to upload the package to the package repository, but I forgot to check for name conflicts! Upon trying to publish the package candidate, I learned that there is an existing packaged named hR. Since I was conflicted anyway, I decided to just not upload the package to the package repository.

I added instructions for using the library to the README in addition to a minimal example, showing how to configure an external dependency. The 0.3.0.1 release includes these changes.

CLI

The CLI now includes an option to read a note from STDIN. When input it read, a timeout is used to ensure that hr does not “hang” when there is no input. There are also new options for specifying a fixed rule width as well as the default rule width to use when the width of the terminal cannot be determined.

Usage: hr [-w|--width CHARS] [-d|--default CHARS] [-a|--ascii] [-t|--time]
          [-f|--format FORMAT] [-i|--input] [--timeout MS] [NOTE ...]
  horizontal rule for the terminal

Available options:
  -h,--help                show help and exit
  --version                show version and exit
  -w,--width CHARS         target rule width (default: terminal width)
  -d,--default CHARS       default target rule width (default: 80)
  -a,--ascii               use ASCII lines (default: use Unicode lines)
  -t,--time                show time
  -f,--format FORMAT       time format (default: %Y-%m-%d %H:%M:%S)
  -i,--input               read note from STDIN within MS milliseconds
  --timeout MS             timeout in milliseconds (default: 500)
  NOTE ...                 show a note

FORMAT codes:
  %Y  four-digit year
  %y  two-digit year
  %m  two-digit month
  %d  two-digit day
  %H  two-digit hour using 24-hour clock
  %I  two-digit hour using 12-hour clock
  %p  locale equivalent of AM or PM
  %M  two-digit minute
  %S  two-digit second
  %q  twelve-digit picosecond
  %z  UTC offset
Author

Travis Cardwell

Published

Tags