projects
/
account.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
bb2e6a4
)
Added the scanning of command line arguments.
author
Arjen Baart
<arjen@andromeda.nl>
Wed, 18 May 2011 15:34:38 +0000
(17:34 +0200)
committer
Arjen Baart
<arjen@andromeda.nl>
Wed, 18 May 2011 15:34:38 +0000
(17:34 +0200)
The input file of bank mutations is now named in a command line argument
instead of always using a file named 'mut.txt'.
bank.cpp
patch
|
blob
|
history
diff --git
a/bank.cpp
b/bank.cpp
index
8e46444
..
f81cd14
100644
(file)
--- a/
bank.cpp
+++ b/
bank.cpp
@@
-16,6
+16,7
@@
#include <vector>
#include <AXE/String.h>
#include <AXE/date.h>
#include <vector>
#include <AXE/String.h>
#include <AXE/date.h>
+#include <getopt.h>
class BankTemplate
{
class BankTemplate
{
@@
-131,12
+132,54
@@
const int DESCRIP4 = 13;
const int DESCRIP5 = 14;
const int DESCRIP6 = 15;
const int DESCRIP5 = 14;
const int DESCRIP6 = 15;
-main()
+static char helptext[] =
+ "Usage: bank [options] filename\n"
+ "\n"
+ "Options:\n"
+ " --help : Print this helpful message\n"
+ " -V\n"
+ " --version : Print the version number\n";
+
+static struct option long_options[] =
+{
+ { "help", no_argument, 0, 'h' },
+ { "version", no_argument, 0, 'V' },
+ { 0, 0, 0, 0 }
+};
+
+main(int argc, char *argv[])
{
{
+ int c;
+
+ int option_index = 0;
+
+ while ((c = getopt_long(argc, argv, "hV", long_options, &option_index)) != -1)
+ {
+ switch (c)
+ {
+ case 'h':
+ std::cout << helptext;
+ exit(0);
+ break;
+
+ case 'V':
+ std::cout << "bank version 1.1\n";
+ exit(0);
+ break;
+
+ }
+ }
+
+ if (optind == argc)
+ {
+ std::cerr << "Usage: bank [options] filename\n";
+ exit(1);
+ }
+
//read_templates("Bank.templ");
std::vector<BankTemplate> templates = read_templates("Bank.templ");
//read_templates("Bank.templ");
std::vector<BankTemplate> templates = read_templates("Bank.templ");
- read_mutations(
"mut.txt"
, templates);
+ read_mutations(
argv[optind]
, templates);
}
std::vector<BankTemplate> read_templates(const char * filename)
}
std::vector<BankTemplate> read_templates(const char * filename)