ssnail

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

commit 85d7b8bf1b19ac6437551864e013de6ae61c0554
parent 9771af0e6dd4501205fd737aa2203361dd0c2102
Author: Paco Esteban <paco@e1e0.net>
Date:   Tue, 16 Jun 2020 19:06:53 +0200

make src_folder and dst_folder arguments as they are mandatory

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

diff --git a/ssnail.c b/ssnail.c @@ -51,6 +51,7 @@ struct article { struct article *a = NULL; SLIST_HEAD(listhead, article) head; +extern char *__progname; void articleq_free(struct listhead *); int gen_html(struct article *); @@ -61,10 +62,11 @@ void usage(); int write_html(struct article *, char *, char *); void -usage() +usage(void) { - // TODO - printf("usage\n"); + (void)fprintf(stderr, + "usage: %s [-F footer] [-H header] [-f] [-i] " + "src_folder dest_folder\n", __progname); exit(1); } @@ -80,7 +82,7 @@ main(int argc, char *argv[]) *fbuf = NULL; struct article *ap = NULL; - while ((ch = getopt(argc, argv, "F:H:d:fis:")) != -1) { + while ((ch = getopt(argc, argv, "F:H:fi")) != -1) { switch (ch) { case 'F': (void)strlcpy(footer_tpl, optarg, PATH_MAX); @@ -88,18 +90,12 @@ main(int argc, char *argv[]) case 'H': (void)strlcpy(header_tpl, optarg, PATH_MAX); break; - case 'd': - (void)strlcpy(dstdir, optarg, PATH_MAX); - break; case 'f': force = 1; break; case 'i': index = 1; break; - case 's': - (void)strlcpy(srcdir, optarg, PATH_MAX); - break; default: usage(); } @@ -109,9 +105,12 @@ main(int argc, char *argv[]) SLIST_INIT(&head); // init the linked list // src and dst dir are mandatory. - if (srcdir[0] == '\0' || dstdir[0] == '\0') + if (argc < 2) usage(); + (void)strlcpy(srcdir, argv[0], PATH_MAX); + (void)strlcpy(dstdir, argv[1], PATH_MAX); + if (process_dir(srcdir, dstdir, force) == -1) err(1, "cannot process src dir");