aboutsummaryrefslogtreecommitdiff
path: root/src/revela.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/revela.c')
-rw-r--r--src/revela.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/revela.c b/src/revela.c
index 32867c6..e21ae02 100644
--- a/src/revela.c
+++ b/src/revela.c
@@ -10,13 +10,18 @@
#include "config.h"
#include "bstree.h"
+#ifndef VERSION
+#define VERSION "0.1.0"
+#endif
+
static const char *usage =
- "Usage: %s [options] [-i <input dir>] -o <output dir>\n";
+ "Usage: %s [OPTIONS] -o <output dir>\n"
+ "For more information consult `man 1 revela`\n";
static struct site site = {0};
static enum log_level loglvl = LOG_DETAIL;
-static void
+static inline void
bad_arguments(const char *cmd)
{
fprintf(stderr, usage, cmd);
@@ -28,17 +33,23 @@ parse_arguments(int argc, char *argv[])
{
int opt;
char *cmd = argv[0];
- while ((opt = getopt(argc, argv, "i:o:n")) != -1) {
+ while ((opt = getopt(argc, argv, "i:o:nhV")) != -1) {
switch (opt) {
case 'i':
site.root_dir = strdup(optarg);
break;
case 'o':
- site.output_dir = optarg;
+ site.output_dir = realpath(optarg, NULL);
break;
case 'n':
site.dry_run = true;
break;
+ case 'h':
+ printf(usage, cmd);
+ exit(0);
+ case 'V':
+ printf("revela "VERSION"\n");
+ exit(0);
default:
bad_arguments(cmd);
}
@@ -51,8 +62,6 @@ parse_arguments(int argc, char *argv[])
int
main(int argc, char *argv[])
{
- int ret = EXIT_SUCCESS;
-
parse_arguments(argc, argv);
#ifdef DEBUG
@@ -61,7 +70,7 @@ main(int argc, char *argv[])
log_set_verbosity(loglvl);
#endif
- ret = site_init(&site) && site_load(&site) && site_build(&site)
+ int ret = site_init(&site) && site_load(&site) && site_build(&site)
? EXIT_SUCCESS : EXIT_FAILURE;
if (site.dry_run) {
@@ -69,5 +78,6 @@ main(int argc, char *argv[])
}
site_deinit(&site);
+
return ret;
}