diff options
-rw-r--r-- | man/blogc.1.ronn | 12 | ||||
-rw-r--r-- | src/blogc/main.c | 15 |
2 files changed, 19 insertions, 8 deletions
diff --git a/man/blogc.1.ronn b/man/blogc.1.ronn index 96b7874..eb64420 100644 --- a/man/blogc.1.ronn +++ b/man/blogc.1.ronn @@ -58,9 +58,15 @@ designed to be used with make(1). See blogc-template(7) for details. * `-p` <KEY>: - Show the value of a global configuration parameter right after the source - parsing and exits. This is useful to get parameters for your `Makefile`, - like the last page when using pagination, see blogc-pagination(7) for details. + Show the value of a variable right after the source parsing and exits. This + is useful to get parameters for your `Makefile`, like the last page when + implementing pagination, see blogc-pagination(7) for details. This can be + also useful to dump variables defined in a source file without parsing it + manually, if called without `-l`. Please note that variables generated by + blogc during rendering process, like `BLOGC_RUSAGE_MEMORY` are not available + because blogc will exit without rendering any content when called with this + option, and will not even require a template, but variables generated during + parsing process, like `CONTENT` are available. * `-t` <TEMPLATE>: Template file. It is a required option, if `blogc` needs to render something. diff --git a/src/blogc/main.c b/src/blogc/main.c index 0e6bcc9..1ca0e82 100644 --- a/src/blogc/main.c +++ b/src/blogc/main.c @@ -60,9 +60,8 @@ blogc_print_help(void) " -d enable debug\n" " -i read list of source files from standard input\n" " -l build listing page, from multiple source files\n" - " -D KEY=VALUE set global configuration parameter\n" - " -p KEY show the value of a global configuration parameter\n" - " after source parsing and exit\n" + " -D KEY=VALUE set global variable\n" + " -p KEY show the value of a variable after source parsing and exit\n" " -t TEMPLATE template file\n" " -o OUTPUT output file\n" #ifdef MAKE_EMBEDDED @@ -292,9 +291,15 @@ main(int argc, char **argv) } if (print != NULL) { - const char *val = bc_trie_lookup(config, print); + const char *val = NULL; + if (!listing && s != NULL) { + val = bc_trie_lookup(s->data, print); + } + if (val == NULL) { + val = bc_trie_lookup(config, print); + } if (val == NULL) { - fprintf(stderr, "blogc: error: configuration variable not found: %s\n", + fprintf(stderr, "blogc: error: variable not found: %s\n", print); rv = 3; } |