Add version option
This commit is contained in:
parent
c87debfbae
commit
8dd7876ebc
12
calathea.c
12
calathea.c
|
@ -8,6 +8,8 @@
|
||||||
#include <argp.h>
|
#include <argp.h>
|
||||||
#include <cmark.h>
|
#include <cmark.h>
|
||||||
|
|
||||||
|
static const char *VERSION = "1.0.0-beta.1";
|
||||||
|
|
||||||
// Structure defining the content and metadata of a single page
|
// Structure defining the content and metadata of a single page
|
||||||
struct Page {
|
struct Page {
|
||||||
char title[80];
|
char title[80];
|
||||||
|
@ -220,6 +222,7 @@ char * substitute_string(char dest[], char sub[], char *start, char *end) {
|
||||||
|
|
||||||
static struct argp_option options[] = {
|
static struct argp_option options[] = {
|
||||||
{ "src", 's', "dir", 0, "Source directory of pages", 0 },
|
{ "src", 's', "dir", 0, "Source directory of pages", 0 },
|
||||||
|
{ "version", 'v', 0, 0, "Print the version", 0 },
|
||||||
{ "template", 't', "file", 0, "Template file path", 0 },
|
{ "template", 't', "file", 0, "Template file path", 0 },
|
||||||
{ "output", 'o', "dir", 0, "Output directory", 0 },
|
{ "output", 'o', "dir", 0, "Output directory", 0 },
|
||||||
{ 0 }
|
{ 0 }
|
||||||
|
@ -230,6 +233,9 @@ static char *templateFileName = "./template.html";
|
||||||
static char *outputDirectoryName = "./build";
|
static char *outputDirectoryName = "./build";
|
||||||
|
|
||||||
static int parse_opt(int key, char *arg, struct argp_state *state) {
|
static int parse_opt(int key, char *arg, struct argp_state *state) {
|
||||||
|
// Suppress unused parameter warnings
|
||||||
|
(void) state;
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 's': {
|
case 's': {
|
||||||
pagesLocation = arg;
|
pagesLocation = arg;
|
||||||
|
@ -243,6 +249,10 @@ static int parse_opt(int key, char *arg, struct argp_state *state) {
|
||||||
outputDirectoryName = arg;
|
outputDirectoryName = arg;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'v': {
|
||||||
|
printf("v%s\n", VERSION);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -251,7 +261,7 @@ static int parse_opt(int key, char *arg, struct argp_state *state) {
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
int initialInboundCapacity = 2;
|
int initialInboundCapacity = 2;
|
||||||
|
|
||||||
struct argp argp = {options, parse_opt, 0, 0 };
|
struct argp argp = {options, parse_opt, 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
argp_parse(&argp, argc, argv, 0, 0, 0);
|
argp_parse(&argp, argc, argv, 0, 0, 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue