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 "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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user