aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-01-25 18:04:33 +0000
committerDavid Robillard <d@drobilla.net>2011-01-25 18:04:33 +0000
commitb06ab736333cbcf7fd411bd7c6badf3f12d75ac2 (patch)
tree290db949f0cd3ec77b09c4a9dd55d8fe5d48b981 /src
parent5b0c4fec31b17b92d01f4eeccfd4bc4af8484865 (diff)
downloadserd-b06ab736333cbcf7fd411bd7c6badf3f12d75ac2.tar.gz
serd-b06ab736333cbcf7fd411bd7c6badf3f12d75ac2.tar.bz2
serd-b06ab736333cbcf7fd411bd7c6badf3f12d75ac2.zip
Add standard command line stuff (-h and -v).
git-svn-id: http://svn.drobilla.net/serd/trunk@68 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src')
-rw-r--r--src/serdi.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/serdi.c b/src/serdi.c
index 5ab5e440..fb104fbd 100644
--- a/src/serdi.c
+++ b/src/serdi.c
@@ -20,6 +20,7 @@
#include <string.h>
#include "serd/serd.h"
+#include "serd-config.h"
// #define URI_DEBUG 1
@@ -178,11 +179,26 @@ event_end(void* handle,
}
int
+print_version()
+{
+ printf("serdi " SERD_VERSION "\n");
+ printf("Copyright (C) 2011 David Robillard <http://drobilla.net>.\n"
+ "\nLicense: GNU LGPL version 3 or later "
+ "<http://gnu.org/licenses/lgpl.html>.\n"
+ "This is free software; you are free to change and redistribute it."
+ "\nThere is NO WARRANTY, to the extent permitted by law.\n");
+ return 0;
+}
+
+int
print_usage(const char* name, bool error)
{
FILE* const os = error ? stderr : stdout;
- fprintf(os, "Usage: %s INPUT [BASE_URI]\n", name);
- fprintf(os, "Read and write RDF syntax.\n");
+ fprintf(os, "Usage: %s [OPTION]... INPUT [BASE_URI]\n", name);
+ fprintf(os, "Read and write RDF syntax.\n\n");
+ fprintf(os, " -h Display this help and exit\n");
+ fprintf(os, " -o SYNTAX Output syntax (`turtle' or `ntriples')\n");
+ fprintf(os, " -v Display version information and exit\n");
return error ? 1 : 0;
}
@@ -208,6 +224,10 @@ main(int argc, char** argv)
if (argv[a][1] == '\0') {
in_fd = stdin;
break;
+ } else if (argv[a][1] == 'h') {
+ return print_usage(argv[0], false);
+ } else if (argv[a][1] == 'v') {
+ return print_version();
} else if (argv[a][1] == 'o') {
if (++a == argc) {
fprintf(stderr, "missing value for -i\n");