diff options
author | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2022-03-31 02:06:41 +0300 |
---|---|---|
committer | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2022-03-31 02:06:41 +0300 |
commit | 3c7230c191ade30d5b9c8ef02a019ba42ab519f5 (patch) | |
tree | 7e85927e11ae604020c547cfe62c3aaa18cfe6f8 /src/revela.c | |
parent | c251b0d5a905f19498e1d3312041b794e57fd2f8 (diff) | |
download | revela-3c7230c191ade30d5b9c8ef02a019ba42ab519f5.tar.gz revela-3c7230c191ade30d5b9c8ef02a019ba42ab519f5.zip |
Ready for packagingv0.1.0
* Documentation
* make install/uninstall
* roscha truthy fix
* Other fixes/improvements
Diffstat (limited to 'src/revela.c')
-rw-r--r-- | src/revela.c | 24 |
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; } |