start using getopt to parse arguments

This commit is contained in:
Josh Holtrop 2016-06-02 13:59:53 -04:00
parent a1bf890b7c
commit b530c82dca
2 changed files with 22 additions and 9 deletions

View File

@ -1,18 +1,30 @@
#include <iostream>
#include "SvnRunner.h"
#include <getopt.h>
using namespace std;
enum
{
OPT_VERSION = 256,
};
int main(int argc, char * argv[])
{
cout << "Hello there." << endl;
SvnRunner runner({"ls"});
for(;;)
static char const optstring[] = "+";
static struct option const longopts[] = {
{"version", no_argument, NULL, OPT_VERSION},
{NULL, 0, NULL, 0},
};
for (int o; (o = getopt_long(argc, argv, optstring, longopts, NULL)) != -1; )
{
const char * line = runner.get_line();
if (line == NULL)
switch (o)
{
case OPT_VERSION:
printf("version 0.0.0alpha0\n");
break;
fprintf(stdout, ">> %s", line);
}
}
fprintf(stdout, "Exit status: %d\n", runner.status());
return 0;
}

View File

@ -1,8 +1,9 @@
def options(opt):
opt.load("compiler_cxx")
def configure(cnf):
cnf.load("compiler_cxx")
def configure(conf):
conf.load("compiler_cxx")
conf.check(header_name = "getopt.h")
def build(bld):
bld(features = "cxx cxxprogram",