From 20bcd2776c43a8580f7f1c719826cbc5876bc17d Mon Sep 17 00:00:00 2001 From: Adam Fordsmand Date: Wed, 28 Sep 2022 23:33:21 +0200 Subject: [PATCH] Implemented --new --- focussg.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/focussg.c b/focussg.c index bee781d..5ee93a4 100644 --- a/focussg.c +++ b/focussg.c @@ -5,12 +5,17 @@ #include #include "BlogDB.h" +static int ArgNewPost(); static int ArgAddAuthor(); static int HelpMessage(); static int VersionMessage(); static int ShortArg(char currentArg[], int argIndex, char *argv[]); static int LongArg(char currentArg[], int argIndex, char *argv[]); +int ArgNewPost() +{ + BlogWrite(NULL); +} int ArgAddAuthor() { @@ -40,6 +45,7 @@ int HelpMessage() printf("Usage: focussg [OPTION]\n"); printf("FoCuSSG (Fordsmand's C Static Site Generator)\n"); printf("\n"); + printf(" -n, --new Open up $EDITOR and add saved post to database\n"); printf(" --add-author Add another author to the database\n"); printf(" -h, --help Show this help message.\n"); printf(" -V, --version Show the version number of FoCuSSG.\n"); @@ -63,6 +69,9 @@ int ShortArg(char currentArg[], int argIndex, char *argv[]) for (int i = 0; i < count; ++i) { switch (options[i]) { + case 'n': + ArgNewPost(); + break; case 'h': HelpMessage(); break; @@ -86,6 +95,8 @@ int LongArg(char currentArg[], int argIndex, char *argv[]) if (strcmp(option, "help") == 0) HelpMessage(); + else if (strcmp(option, "new") == 0) + ArgNewPost(); else if (strcmp(option, "add-author") == 0) ArgAddAuthor(); else if (strcmp(option, "version") == 0)