A Configurable Status Line for HCat

Using what you’ve learned in this chapter, revisit the HCat application that you built earlier. Update HCat to support a configurable status bar that will show up at the bottom of the output. The status bar configuration should be stored on disk in a configuration file (for example ~/.config/hcat.conf ). Allow users to specify which fields they want to see, what order they should appear in, and the maximum width of each field.

Command Line Argument Parsing

Several of the examples that you’ve worked on in this book have required you to deal with command line arguments. So far, we’ve dealt with this in an ad hoc manner. Using what you’ve learned in this chapter, try to build a library to make it easier to work with command line arguments. Use this library to improve the command line argument handling for your filepack parsing program and the HCat application you built earlier.

Pretty Printing and Parsing

Reversible parsing is a technique that lets you write a parser that can also be used to encode data. This is particularly useful when you want to impelement parsing for files like JSON, XML, or our own FilePack format. A common use for reversible parsing is to implement a “pretty printing” tool that will let users reformat a document so that it’s more readable.

Using what you’ve learned in this chapter, try to implement a parser for a simple plain text format, and then make the parser reversible. Your reversible parser should reformat the original input so that it’s easier to read.

Footnotes

[19]

http://netpbm.sourceforge.net/

Copyright © 2023, The Pragmatic Bookshelf.