ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/gclib/gtest.cpp
Revision: 99
Committed: Thu Oct 6 20:49:17 2011 UTC (7 years, 6 months ago) by gpertea
File size: 1905 byte(s)
Log Message:
wip

Line User Rev File contents
1 gpertea 18 #include "GBase.h"
2     #include "GArgs.h"
3     #include "GStr.h"
4    
5     #define USAGE "Usage:\n\
6     gtest [-g|--genomic-fasta <genomic_seqs_fasta>] [-c|COV=<cov%>] \n\
7     [-s|--seq <seq_info.fsize>] [-o|--out <outfile.gff>] [--disable-flag] [-t|--test <string>]\n\
8     [-p|PID=<pid%>] file1 [file2 file3 ..]\n\
9     "
10     enum {
11     OPT_HELP=1,
12     OPT_GENOMIC,
13     OPT_COV,
14     OPT_SEQ,
15     OPT_OUTFILE,
16     OPT_DISABLE_FLAG,
17     OPT_TEST,
18     OPT_PID,
19     };
20    
21     GArgsDef opts[] = {
22     {"help", 'h', 0, OPT_HELP},
23     {"genomic-fasta", 'g', 1, OPT_GENOMIC},
24     {"COV", 'c', 1, OPT_COV},
25     {"seq", 's', 1, OPT_SEQ},
26     {"out", 'o', 1, OPT_OUTFILE},
27     {"disable-flag", 0, 0, OPT_DISABLE_FLAG},
28     {"test", 't', 1, OPT_TEST},
29     {"PID", 'p', 1, OPT_PID},
30     {0,0,0,0}
31     };
32    
33     int main(int argc, char * const argv[]) {
34     //GArgs args(argc, argv, "hg:c:s:t:o:p:help;genomic-fasta=COV=PID=seq=out=disable-flag;test=");
35     GArgs args(argc, argv, opts);
36     fprintf(stderr, "Command line was:\n");
37     args.printCmdLine(stderr);
38     args.printError(USAGE, true);
39     //if (args.getOpt('h') || args.getOpt("help"))
40     if (args.getOpt(OPT_HELP))
41     {
42     GMessage("%s\n", USAGE);
43     exit(1);
44     }
45     int numopts=args.startOpt();
46     if (numopts)
47     GMessage("#### Recognized %d option arguments:\n", numopts);
48     int optcode=0;
49     while ((optcode=args.nextCode())) {
50     char* r=args.getOpt(optcode);
51     GMessage("%14s\t= %s\n", args.getOptName(optcode), (r[0]==0)?"True":r);
52     }
53     int numargs=args.startNonOpt();
54     if (numargs>0) {
55     GMessage("\n#### Found %d non-option arguments given:\n", numargs);
56     char* a=NULL;
57     while ((a=args.nextNonOpt())) {
58     GMessage("%s\n",a);
59     }
60     }
61 gpertea 99 GStr s=args.getOpt('t');
62     if (!s.is_empty()) {
63     GStr token;
64     GMessage("Tokens in \"%s\" :\n",s.chars());
65     s.startTokenize(";,: \t");
66     int c=1;
67     while (s.nextToken(token)) {
68     GMessage("token %2d : \"%s\"\n",c,token.chars());
69     c++;
70     }
71     }
72 gpertea 18 }