ssnail

crappy and opinionated static site generator
git clone https://git.e1e0.net/ssnail.git
Log | Files | Refs | README | LICENSE

commit 7e2cec0aa0face7fe3b55c9f784da0332e2d289e
parent b84e437384d5d18cdb9e31f039535fe4c1840935
Author: Paco Esteban <paco@e1e0.net>
Date:   Sun, 24 May 2020 18:24:24 +0200

sort getopt and add force flag

Diffstat:
Mssnail.c | 21++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/ssnail.c b/ssnail.c @@ -62,26 +62,29 @@ main(int argc, char *argv[]) { DIR *dirp; struct dirent *dp; - int ch; + int ch, force = 0; char srcdir[PATH_MAX] = "", dstdir[PATH_MAX] = "", header_tpl[PATH_MAX] = "./_header.html", footer_tpl[PATH_MAX] = "./_footer.html", *fbuf = NULL; struct article *ap = NULL; - while ((ch = getopt(argc, argv, "s:d:H:F:")) != -1) { + while ((ch = getopt(argc, argv, "F:H:d:fs:")) != -1) { switch (ch) { - case 's': - (void)strlcpy(srcdir, optarg, PATH_MAX); + case 'F': + (void)strlcpy(footer_tpl, optarg, PATH_MAX); + break; + case 'H': + (void)strlcpy(header_tpl, optarg, PATH_MAX); break; case 'd': (void)strlcpy(dstdir, optarg, PATH_MAX); break; - case 'H': - (void)strlcpy(header_tpl, optarg, PATH_MAX); + case 'f': + force = 1; break; - case 'F': - (void)strlcpy(footer_tpl, optarg, PATH_MAX); + case 's': + (void)strlcpy(srcdir, optarg, PATH_MAX); break; default: usage(); @@ -116,7 +119,7 @@ main(int argc, char *argv[]) printf("Generating html files ... \n"); SLIST_FOREACH(ap, &head, entries) { - if (ap->src_mtime > ap->dst_mtime) { + if ((ap->src_mtime > ap->dst_mtime) || force) { printf("... %s\n", ap->dst_path); if (write_html(ap, header_tpl, footer_tpl) == -1) err(3, "cannot write html file");