From 49fe49f7f0c6ad3ec81fbcbcd266ce627379182a Mon Sep 17 00:00:00 2001 From: Barattero Laurent Date: Wed, 29 Jan 2014 13:15:33 +0100 Subject: Fix getoptlong --version --- src/main.cpp | 141 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 73 insertions(+), 68 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index b385006..e9cf981 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -98,75 +98,80 @@ main ( int argc, char *argv[] ) switch (c) { - case 'o': - manager.addItemStart(optarg); - break; - - case 't': - manager.addItemTest(optarg); - break; - - case 'c': - try - { - manager.subRoutine(FLAG_COLOR); - } - catch ( const string & Msg ) - { - cerr << "Error : " << Msg << endl; - return(EXIT_FAILURE); - } - break; - - case 'G': - manager.addItemGetSerial(optarg); - break; - - case 'S': - try - { - manager.subRoutine(FLAG_SET_SER); - } - catch ( const string & Msg ) - { - cerr << "Error : " << Msg << endl; - return(EXIT_FAILURE); - } - break; + case 0: + /* If this option set a flag, do nothing else now. */ + if (long_options[option_index].flag != 0) + break; + + case 'o': + manager.addItemStart(optarg); + break; + + case 't': + manager.addItemTest(optarg); + break; + + case 'c': + try + { + manager.subRoutine(FLAG_COLOR); + } + catch ( const string & Msg ) + { + cerr << "Error : " << Msg << endl; + return(EXIT_FAILURE); + } + break; + + case 'G': + manager.addItemGetSerial(optarg); + break; + + case 'S': + try + { + manager.subRoutine(FLAG_SET_SER); + } + catch ( const string & Msg ) + { + cerr << "Error : " << Msg << endl; + return(EXIT_FAILURE); + } + break; - case 'i': - manager.addItemVerify(optarg); - break; - - case 'u': - manager.subRoutine(FLAG_UP_GLO); - break; - - case 'U': - manager.subRoutine(FLAG_UP_GLOC); - break; - - case 'k': - manager.addItemSymlink(optarg); - break; - - case 'v': - VERBOSE_AERO = true; - break; - - case 'h': - help = 1; - break; - - case '?': - /* getopt_long already printed an error message. */ - puts("To get help : 'aeroup --help' or 'man aeroup'"); - return EXIT_FAILURE; - break; - - default: - abort (); - } + case 'i': + manager.addItemVerify(optarg); + break; + + case 'u': + manager.subRoutine(FLAG_UP_GLO); + break; + + case 'U': + manager.subRoutine(FLAG_UP_GLOC); + break; + + case 'k': + manager.addItemSymlink(optarg); + break; + + case 'v': + VERBOSE_AERO = true; + break; + + case 'h': + help = 1; + break; + + case '?': + /* getopt_long already printed an error message. */ + puts("To get help : 'aeroup --help' or 'man aeroup'"); + return EXIT_FAILURE; + break; + + default: + abort (); + } } /* Print any remaining command line arguments (not options). */ -- cgit v1.2.3