[OSD600] Build a static site generator with Picocli

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 input file or folder to be processed, using --input or -i . Then it generates one .html output file for each input file and the filename is based on the title of the story’s header.
  • jssg places all output into a ./dist folder by default. Each time the tool is run, an existing dist folder should first be removed so that dist always contains the last output. For example, if I run --input on a file “Silver Blaze.txt”
  • For the previous demos, --output or -o werent’s specified and dist was used. If the user specifies a different output path (--output or -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

Computer Programming Student @Seneca. Writing to share solutions and encourage my sister to write.