Ticket #5935: 00-5935-mythwelcome-showusage.2.patch
File 00-5935-mythwelcome-showusage.2.patch, 4.0 KB (added by , 15 years ago) |
---|
-
mythtv/programs/mythwelcome/main.cpp
20 20 #include "mythuihelper.h" 21 21 #include "lcddevice.h" 22 22 #include "myththemebase.h" 23 #include "mythcommandlineparser.h" 23 24 24 25 #include "libmythtv/tv.h" 25 26 … … 41 42 REG_KEY("Welcome", "STARTSETUP", "Start Mythtv-Setup", ""); 42 43 } 43 44 45 void showUsage(const MythCommandLineParser &cmdlineparser) 46 { 47 QString help = cmdlineparser.GetHelpString(false); 48 QByteArray ahelp = help.toLocal8Bit(); 49 50 QString binname = "mythwelcome"; 51 52 extern const char *myth_source_version; 53 extern const char *myth_source_path; 54 55 VERBOSE(VB_IMPORTANT, QString("%1 version: %2 [%3] www.mythtv.org") 56 .arg(binname) 57 .arg(myth_source_path) 58 .arg(myth_source_version)); 59 60 cerr << "Valid options are: " << endl << 61 "-v or --verbose debug-level Use '-v help' for level info" << endl << 62 "-s or --setup Run setup for the mythshutdown program" << endl << 63 "-l or --logfile filename Writes STDERR and STDOUT messages to filename" << endl << 64 ahelp.constData() << 65 endl; 66 67 } 68 44 69 int main(int argc, char **argv) 45 70 { 46 71 bool bShowSettings = false; 47 72 48 QApplication a(argc, argv); 73 bool cmdline_err; 74 75 MythCommandLineParser cmdline( 76 kCLPOverrideSettingsFile | 77 kCLPOverrideSettings | 78 kCLPQueryVersion); 49 79 50 gContext = NULL; 51 gContext = new MythContext(MYTH_BINARY_VERSION); 52 if (!gContext->Init()) 80 for (int argpos = 0; argpos < argc; ++argpos) 53 81 { 54 VERBOSE(VB_IMPORTANT, "mythwelcome: Could not initialize myth context. "55 "Exiting.");56 return FRONTEND_EXIT_NO_MYTHCONTEXT;57 }82 if (cmdline.PreParse(argc, argv, argpos, cmdline_err)) 83 { 84 if (cmdline_err) 85 return BACKEND_EXIT_INVALID_CMDLINE; 58 86 59 if (!MSqlQuery::testDBConnection()) 60 { 61 VERBOSE(VB_IMPORTANT, "mythwelcome: Could not open the database. " 62 "Exiting."); 63 return -1; 87 if (cmdline.WantsToExit()) 88 return BACKEND_EXIT_OK; 89 } 64 90 } 91 92 QApplication a(argc, argv); 65 93 66 94 // Check command line arguments 67 95 for (int argpos = 1; argpos < a.argc(); ++argpos) … … 110 138 return FRONTEND_EXIT_INVALID_CMDLINE; 111 139 } 112 140 } 141 else if (cmdline.Parse(a.argc(), a.argv(), argpos, cmdline_err)) 142 { 143 if (cmdline_err) 144 return BACKEND_EXIT_INVALID_CMDLINE; 145 146 if (cmdline.WantsToExit()) 147 return BACKEND_EXIT_OK; 148 } 113 149 else 114 150 { 115 cerr << "Invalid argument: " << a.argv()[argpos] << endl << 116 "Valid options are: " << endl << 117 "-v or --verbose debug-level Use '-v help' for level info" << endl << 118 "-s or --setup Run setup for the mythshutdown program" << endl << 119 "-l or --logfile filename Writes STDERR and STDOUT messages to filename" << endl; 151 showUsage(cmdline); 120 152 return FRONTEND_EXIT_INVALID_CMDLINE; 121 153 } 122 154 } 123 155 156 gContext = NULL; 157 gContext = new MythContext(MYTH_BINARY_VERSION); 158 if (!gContext->Init()) 159 { 160 VERBOSE(VB_IMPORTANT, "mythwelcome: Could not initialize myth context. " 161 "Exiting."); 162 return FRONTEND_EXIT_NO_MYTHCONTEXT; 163 } 164 165 if (!MSqlQuery::testDBConnection()) 166 { 167 VERBOSE(VB_IMPORTANT, "mythwelcome: Could not open the database. " 168 "Exiting."); 169 return -1; 170 } 171 124 172 if (logfile != "") 125 173 { 126 174 if (!log_rotate(true))