commit:7034e4be0e5b0cd1a27a067fee5970cf61500b60
author:Chip Black
committer:Chip Black
date:Sat Nov 23 20:19:22 2013 -0600
parents:4a1ef10deb4ba66c2008a21865b9ed07a7e88def
Add subscribe/unsubscribe to blergtool
diff --git a/tools/blergtool.c b/tools/blergtool.c
line changes: +32/-1
index ab98a94..35af915
--- a/tools/blergtool.c
+++ b/tools/blergtool.c
@@ -7,7 +7,18 @@
 #include "tags.h"
 
 void help() {
-	printf("Usage: blergtool <store|fetch> <storename> [record]\n");
+	printf(
+	  "Usage: blergtool <command> [args]\n"
+	  "\n"
+	  "Where command is one of:\n"
+	  "\n"
+	  "  blergtool store <storename>\n"
+	  "  blergtool fetch <storename> [record]\n"
+	  "  blergtool mute <storename>\n"
+	  "  blergtool unmute <storename>\n"
+	  "  blergtool subscribe <storename> <target>\n"
+	  "  blergtool unsubscribe <storename> <target>\n"
+	);
 }
 
 int main(int argc, char *argv[]) {
@@ -88,6 +99,26 @@ int main(int argc, char *argv[]) {
 
 		blerg_set_mute(f, 0);
 		blerg_close(f);
+	} else if (strncmp(argv[1], "subscribe", 9) == 0) {
+		if (argc < 4) {
+			printf("Not enough arguments for subscribe\n");
+			help();
+			exit(1);
+		}
+		if (!subscription_add(argv[2], argv[3])) {
+			printf("Could not subscribe %s to %s\n", argv[2], argv[3]);
+			exit(1);
+		}
+	} else if (strncmp(argv[1], "unsubscribe", 11) == 0) {
+		if (argc < 4) {
+			printf("Not enough arguments for unsubscribe\n");
+			help();
+			exit(1);
+		}
+		if (!subscription_remove(argv[2], argv[3])) {
+			printf("Could not subscribe %s to %s\n", argv[2], argv[3]);
+			exit(1);
+		}
 	} else {
 		help();
 	}