aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/serdi.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/serdi.c b/src/serdi.c
index 8b72945a..e93d6bcc 100644
--- a/src/serdi.c
+++ b/src/serdi.c
@@ -52,9 +52,10 @@ print_usage(const char* name, 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, "Read and write RDF syntax.\n");
fprintf(os, "Use - for INPUT to read from standard input.\n\n");
+ fprintf(os, " -I BASE_URI Input base URI.\n");
fprintf(os, " -a Write ASCII output if possible.\n");
fprintf(os, " -b Fast bulk output for large serialisations.\n");
fprintf(os, " -c PREFIX Chop PREFIX from matching blank node IDs.\n");
@@ -96,6 +97,7 @@ main(int argc, char** argv)
return print_usage(argv[0], true);
}
+ SerdNode* base = NULL;
SerdSyntax input_syntax = SERD_SYNTAX_EMPTY;
SerdSyntax output_syntax = SERD_SYNTAX_EMPTY;
SerdReaderFlags reader_flags = 0;
@@ -118,7 +120,13 @@ main(int argc, char** argv)
break;
}
- if (argv[a][1] == 'a') {
+ if (argv[a][1] == 'I') {
+ if (++a == argc) {
+ return missing_arg(argv[0], 'I');
+ }
+
+ base = serd_new_uri(SERD_MEASURE_STRING(argv[a]));
+ } else if (argv[a][1] == 'a') {
writer_flags |= SERD_WRITE_ASCII;
} else if (argv[a][1] == 'b') {
bulk_write = true;
@@ -216,10 +224,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_MEASURE_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_MEASURE_STRING(input), SERD_EMPTY_STRING());
}