Implemented --new

This commit is contained in:
Adam Fordsmand 2022-09-28 23:33:21 +02:00
parent 5952d1640b
commit 20bcd2776c
1 changed files with 11 additions and 0 deletions

View File

@ -5,12 +5,17 @@
#include <stdbool.h>
#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)