From 64b6a139080b7d13a70c5bd9febc6e137a0a7eab Mon Sep 17 00:00:00 2001 From: JensHoffmann Date: Thu, 12 Dec 2013 23:24:14 +0100 Subject: [PATCH] Provide long options for oned (cherry picked from commit 1f6da357d55d953d2985f6b44a064efe6b7a38fb) --- src/nebula/oned.cc | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/nebula/oned.cc b/src/nebula/oned.cc index f4db6145a4..d80322bde2 100644 --- a/src/nebula/oned.cc +++ b/src/nebula/oned.cc @@ -19,6 +19,7 @@ #include #include #include +#include #include #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