about summary refs log tree commit diff
path: root/mseq.c
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-07-20 13:46:39 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2016-07-20 13:46:39 +0200
commit30b94679d6f453dc98b3ce2d618b1252bf6b8584 (patch)
tree913935baf59956fc9b23f5f972768e5d0706c6f4 /mseq.c
parentc064b92202dd3581defeb0f8daad87a1cad60772 (diff)
downloadmblaze-30b94679d6f453dc98b3ce2d618b1252bf6b8584.tar.gz
mblaze-30b94679d6f453dc98b3ce2d618b1252bf6b8584.tar.xz
mblaze-30b94679d6f453dc98b3ce2d618b1252bf6b8584.zip
mseq: -n to expand ranges
Diffstat (limited to 'mseq.c')
-rw-r--r--mseq.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/mseq.c b/mseq.c
index 2fba9ad..5ae5862 100644
--- a/mseq.c
+++ b/mseq.c
@@ -4,9 +4,20 @@
 
 #include "blaze822.h"
 
+static int nflag;
+
 int
 main(int argc, char *argv[])
 {
+	int c;
+	while ((c = getopt(argc, argv, "n")) != -1)
+		switch(c) {
+		case 'n': nflag = 1; break;
+		default:
+			// XXX usage
+			exit(1);
+		}
+
 	char *map = blaze822_seq_open(0);
 	if (!map)
 		return 1;
@@ -14,9 +25,12 @@ main(int argc, char *argv[])
 	int i;
 	char *f;
 	struct blaze822_seq_iter iter = { 0 };
-	for (i = 1; i < argc; i++) {
+	for (i = optind; i < argc; i++) {
 		while ((f = blaze822_seq_next(map, argv[i], &iter))) {
-			printf("%s\n", f);
+			if (nflag)
+				printf("%ld\n", iter.line-1);
+			else
+				printf("%s\n", f);
 			free(f);
 		}
 	}