My first assignment in the Open Source course is building a command line to generate an HTML website from .text files… Oh well, anything relating to the operating system is something I have never been confident doing…
But thanks to Picocli — a framework for creating Java command-line applications with almost zero code, it really saved me much time to complete my assignment.
The features I built include
- Display the version of the tool and --help to show a list of command lines
- Allow the user to specify an
inputfile or folder to be processed, using
-i. Then it generates one
.htmloutput file for each input file and the filename is based on the title of the story’s header.
- jssg places all output into a
./distfolder by default. Each time the tool is run, an existing
distfolder should first be removed so that
distalways contains the last output. For example, if I run
--inputon a file “Silver Blaze.txt”
- For the previous demos,
-owerent’s specified and
distwas used. If the user specifies a different output path (
-o), jssg will use that, it also prints an error if the specified output path is not a valid directory.
Piccoli is a great tool, and the document is well written. However, there are some downsides (or probably I still haven’t explored all of its features yet), for example, it doesn’t read spaces in the filenames. I solved this by writing a .bat file.
How to use my tool, installation, and more: https://github.com/trangntt-016/static-site-generator