Merge pull request 'Implemented --new' (#40) from 15-arg-new into command-line-interface
Reviewed-on: #40
This commit is contained in:
commit
ba12606b2c
11
focussg.c
11
focussg.c
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue