Implemented the add-author argument
This commit is contained in:
parent
0b3cc7f5db
commit
c9aeb10f33
31
focussg.c
31
focussg.c
|
|
@ -5,19 +5,44 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "BlogDB.h"
|
#include "BlogDB.h"
|
||||||
|
|
||||||
|
static int ArgAddAuthor();
|
||||||
static int HelpMessage();
|
static int HelpMessage();
|
||||||
static int VersionMessage();
|
static int VersionMessage();
|
||||||
static int ShortArg(char currentArg[], int argIndex, char *argv[]);
|
static int ShortArg(char currentArg[], int argIndex, char *argv[]);
|
||||||
static int LongArg(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()
|
int HelpMessage()
|
||||||
{
|
{
|
||||||
printf("Usage: focussg [OPTION]\n");
|
printf("Usage: focussg [OPTION]\n");
|
||||||
printf("FoCuSSG (Fordsmand's C Static Site Generator)\n");
|
printf("FoCuSSG (Fordsmand's C Static Site Generator)\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf(" -h, --help Show this help message.\n");
|
printf(" --add-author Add another author to the database\n");
|
||||||
printf(" -V, --version Show the version number of FoCuSSG.\n");
|
printf(" -h, --help Show this help message.\n");
|
||||||
|
printf(" -V, --version Show the version number of FoCuSSG.\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,6 +86,8 @@ int LongArg(char currentArg[], int argIndex, char *argv[])
|
||||||
|
|
||||||
if (strcmp(option, "help") == 0)
|
if (strcmp(option, "help") == 0)
|
||||||
HelpMessage();
|
HelpMessage();
|
||||||
|
else if (strcmp(option, "add-author") == 0)
|
||||||
|
ArgAddAuthor();
|
||||||
else if (strcmp(option, "version") == 0)
|
else if (strcmp(option, "version") == 0)
|
||||||
VersionMessage();
|
VersionMessage();
|
||||||
else if (strcmp(option, "") == 0)
|
else if (strcmp(option, "") == 0)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue