1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-16 22:50:10 +03:00

Provide long options for oned

(cherry picked from commit 1f6da357d55d953d2985f6b44a064efe6b7a38fb)
This commit is contained in:
JensHoffmann 2013-12-12 23:24:14 +01:00 committed by Ruben S. Montero
parent 419df715da
commit 64b6a13908

View File

@ -19,6 +19,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <getopt.h>
#include <ostream>
#include "Nebula.h"
@ -49,10 +50,10 @@ static void print_help()
<< "SYNOPSIS\n"
<< " Starts the OpenNebula daemon\n\n"
<< "OPTIONS\n"
<< " -v\toutput version information and exit\n"
<< " -h\tdisplay this help and exit\n"
<< " -f\tforeground, do not fork the oned daemon\n"
<< " -i\tinitialize the dabase and exit\n";
<< " -v, --verbose\toutput version information and exit\n"
<< " -h, --help\tdisplay this help and exit\n"
<< " -f, --foreground\tforeground, do not fork the oned daemon\n"
<< " -i, --init-db\tinitialize the dabase and exit\n";
}
/* ------------------------------------------------------------------------- */
@ -104,7 +105,19 @@ int main(int argc, char **argv)
string wd;
int rc;
while((opt = getopt(argc,argv,"vhif")) != -1)
static struct option long_options[] = {
{"version", no_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{"foreground", no_argument, 0, 'f'},
{"init-db", no_argument, 0, 'i'},
{0, 0, 0, 0}
};
int long_index = 0;
while ((opt = getopt_long(argc, argv, "vhif",
long_options, &long_index)) != -1)
{
switch(opt)
{
case 'v':
@ -127,6 +140,7 @@ int main(int argc, char **argv)
exit(-1);
break;
}
}
// ---------------------------------
// Check if other oned is running