From: peterjc Date: Tue, 3 Apr 2012 11:05:17 +0000 (+0100) Subject: Minimal 'samtools depad' command line parsing (-? only so far) X-Git-Url: https://git.donarmstrong.com/?p=samtools.git;a=commitdiff_plain;h=6714aa07f8d3ec25225cc691066da89ca1bd0e9b Minimal 'samtools depad' command line parsing (-? only so far) --- diff --git a/padding.c b/padding.c index a406612..9fbdb53 100644 --- a/padding.c +++ b/padding.c @@ -1,5 +1,6 @@ #include #include +#include #include "kstring.h" #include "bam.h" @@ -180,11 +181,18 @@ static int usage(int is_long_help); int main_pad2unpad(int argc, char *argv[]) { bamFile in, out; - int is_long_help = 1; + int c, is_long_help = 0; int result=0; - if (argc == 1) { - return usage(is_long_help); - } + + /* parse command-line options */ + while ((c = getopt(argc, argv, "?")) >= 0) { + switch (c) { + case '?': is_long_help = 1; break; + default: return usage(is_long_help); + } + } + if (argc == optind) return usage(is_long_help); + in = strcmp(argv[1], "-")? bam_open(argv[1], "r") : bam_dopen(fileno(stdin), "r"); out = bam_dopen(fileno(stdout), "w"); result = bam_pad2unpad(in, out); @@ -196,7 +204,7 @@ static int usage(int is_long_help) { fprintf(stderr, "\n"); fprintf(stderr, "Usage: samtools depad \n\n"); - fprintf(stderr, "Currently there are no optional arguments.\n"); + fprintf(stderr, "Options: -? longer help\n"); //TODO - These are the arguments I think make sense to support: //fprintf(stderr, "Usage: samtools depad [options] |\n\n"); //fprintf(stderr, "Options: -b output BAM\n");