start using getopt to parse arguments
This commit is contained in:
parent
a1bf890b7c
commit
b530c82dca
26
src/svi.cc
26
src/svi.cc
@ -1,18 +1,30 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "SvnRunner.h"
|
#include "SvnRunner.h"
|
||||||
|
#include <getopt.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
OPT_VERSION = 256,
|
||||||
|
};
|
||||||
|
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
cout << "Hello there." << endl;
|
static char const optstring[] = "+";
|
||||||
SvnRunner runner({"ls"});
|
static struct option const longopts[] = {
|
||||||
for(;;)
|
{"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();
|
switch (o)
|
||||||
if (line == NULL)
|
{
|
||||||
|
case OPT_VERSION:
|
||||||
|
printf("version 0.0.0alpha0\n");
|
||||||
break;
|
break;
|
||||||
fprintf(stdout, ">> %s", line);
|
}
|
||||||
}
|
}
|
||||||
fprintf(stdout, "Exit status: %d\n", runner.status());
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
5
wscript
5
wscript
@ -1,8 +1,9 @@
|
|||||||
def options(opt):
|
def options(opt):
|
||||||
opt.load("compiler_cxx")
|
opt.load("compiler_cxx")
|
||||||
|
|
||||||
def configure(cnf):
|
def configure(conf):
|
||||||
cnf.load("compiler_cxx")
|
conf.load("compiler_cxx")
|
||||||
|
conf.check(header_name = "getopt.h")
|
||||||
|
|
||||||
def build(bld):
|
def build(bld):
|
||||||
bld(features = "cxx cxxprogram",
|
bld(features = "cxx cxxprogram",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user