commit 4b94c5bf811ef1c35f26b69ecc558a9e1c0d9d26
parent 86993965de423bdd9f4cfb146929a1cdd9fbc0b2
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Fri, 2 Jan 2015 21:26:36 +0100
sfeed: add -v flag to display program version
Diffstat:
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/sfeed.1 b/sfeed.1
@@ -5,12 +5,16 @@
.Nm sfeed
.Nd simple RSS and Atom parser
.Sh SYNOPSIS
-.Nm sfeed
-.Op Ar suffix string
+.Nm
+.Op Ar suffix string | Fl Ar v
.Sh DESCRIPTION
.Nm
reads RSS or Atom feed data (XML) from stdin. It writes the feed data in a
tab-separated format to stdout.
+.Sh OPTIONS
+.Bl -tag -width 17n
+.It Fl v
+show program version
.Sh TAB-SEPARATED FORMAT FIELDS
.Pp
The items are saved in a TSV-like format except newlines, tabs and
diff --git a/sfeed.c b/sfeed.c
@@ -727,8 +727,13 @@ xml_handler_end_element(XMLParser *p, const char *name, size_t namelen, int issh
int
main(int argc, char *argv[])
{
- if(argc > 1)
+ if(argc > 1) {
append = argv[1];
+ if(!strcmp(argv[1], "-v")) {
+ printf("%s\n", VERSION);
+ return 0;
+ }
+ }
/* init strings and initial memory pool size */
string_buffer_init(&ctx.item.timestamp, 64);