Merge pull request 'Implemented the add-author argument' (#38) from 23-add-author-arg into command-line-interface

Reviewed-on: #38
This commit is contained in:
Adam Fordsmand 2022-09-28 21:04:11 +00:00
commit 5952d1640b
1 changed files with 29 additions and 2 deletions

View File

@ -5,19 +5,44 @@
#include <stdbool.h>
#include "BlogDB.h"
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 ArgAddAuthor()
{
printf("In order to add a new author provide the following information:\n");
// Define buffers
char firstName[255];
char lastName[255];
char email[255];
printf("First name : ");
scanf("%s", &firstName);
printf("Last name : ");
scanf("%s", &lastName);
printf("Email : ");
scanf("%s", &email);
int userId = AddAuthor(firstName, lastName, email, NULL);
printf("User %s %s (%s) was created with userid %d\n", firstName, lastName, email, userId);
}
int HelpMessage()
{
printf("Usage: focussg [OPTION]\n");
printf("FoCuSSG (Fordsmand's C Static Site Generator)\n");
printf("\n");
printf(" -h, --help Show this help message.\n");
printf(" -V, --version Show the version number of FoCuSSG.\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");
exit(0);
}
@ -61,6 +86,8 @@ int LongArg(char currentArg[], int argIndex, char *argv[])
if (strcmp(option, "help") == 0)
HelpMessage();
else if (strcmp(option, "add-author") == 0)
ArgAddAuthor();
else if (strcmp(option, "version") == 0)
VersionMessage();
else if (strcmp(option, "") == 0)