aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/serd-pipe.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/tools/serd-pipe.c b/tools/serd-pipe.c
index 26a4a26a..a5f2a1b2 100644
--- a/tools/serd-pipe.c
+++ b/tools/serd-pipe.c
@@ -33,6 +33,7 @@ print_usage(const char* const name, const bool error)
static const char* const description =
"Read and write RDF syntax.\n"
"Use - for INPUT to read from standard input.\n\n"
+ " -B BASE_URI Base URI.\n"
" -a Write ASCII output.\n"
" -b Write output in blocks for performance.\n"
" -c PREFIX Chop PREFIX from matching blank node IDs.\n"
@@ -52,7 +53,7 @@ print_usage(const char* const name, const bool error)
FILE* const os = error ? stderr : stdout;
fprintf(os, "%s", error ? "\n" : "");
- fprintf(os, "Usage: %s [OPTION]... INPUT [BASE_URI]\n", name);
+ fprintf(os, "Usage: %s [OPTION]... INPUT\n", name);
fprintf(os, "%s", description);
return error ? 1 : 0;
}
@@ -77,6 +78,7 @@ main(int argc, char** argv)
{
const char* const prog = argv[0];
+ SerdNode* base = NULL;
SerdSyntax input_syntax = SERD_SYNTAX_EMPTY;
SerdSyntax output_syntax = SERD_SYNTAX_EMPTY;
SerdReaderFlags reader_flags = 0;
@@ -131,6 +133,13 @@ main(int argc, char** argv)
} else if (opt == 's') {
from_string = true;
break;
+ } else if (argv[a][1] == 'B') {
+ if (++a == argc) {
+ return missing_arg(prog, 'B');
+ }
+
+ base = serd_new_uri(serd_string(argv[a]));
+ break;
} else if (opt == 'c') {
if (argv[a][o + 1] || ++a == argc) {
return missing_arg(prog, 'c');
@@ -212,10 +221,7 @@ main(int argc, char** argv)
output_syntax = input_has_graphs ? SERD_NQUADS : SERD_NTRIPLES;
}
- SerdNode* base = NULL;
- if (a < argc) { // Base URI given on command line
- base = serd_new_uri(serd_string(argv[a]));
- } else if (!from_string && !from_stdin) { // Use input file URI
+ if (!base && !from_string && !from_stdin) { // Use input file URI
base = serd_new_file_uri(serd_string(input), serd_empty_string());
}