Ticket #7662: help3.patch
File help3.patch, 4.4 KB (added by , 14 years ago) |
---|
-
libs/libmyth/mythcommandlineparser.h
24 24 class MPUBLIC MythCommandLineParser 25 25 { 26 26 public: 27 MythCommandLineParser(int things_to_parse );27 MythCommandLineParser(int things_to_parse, void (*helpFunc)(const MythCommandLineParser&) = NULL); 28 28 29 29 bool PreParse(int argc, const char * const * argv, int &argpos, bool &err); 30 30 bool Parse(int argc, const char * const * argv, int &argpos, bool &err); … … 40 40 bool WantsToExit(void) const { return wantsToExit; } 41 41 42 42 private: 43 QString GetHelpStringInternal(bool with_header) const; 44 43 45 int parseTypes; 44 46 45 47 QMap<QString,QString> settingsOverride; … … 48 50 QString geometry; 49 51 50 52 bool wantsToExit; 53 void (*helpFunction)(const MythCommandLineParser &); 51 54 }; -
libs/libmyth/mythcommandlineparser.cpp
10 10 #include "mythverbose.h" 11 11 #include "mythversion.h" 12 12 13 MythCommandLineParser::MythCommandLineParser(int things_to_parse ) :13 MythCommandLineParser::MythCommandLineParser(int things_to_parse, void (*helpFunc)(const MythCommandLineParser&)) : 14 14 parseTypes(things_to_parse), 15 15 display(QString::null), geometry(QString::null), 16 wantsToExit(false) 16 wantsToExit(false), helpFunction(helpFunc) 17 17 { 18 18 } 19 19 … … 100 100 !strcmp(argv[argpos],"--help") || 101 101 !strcmp(argv[argpos],"--usage"))) 102 102 { 103 QString help = GetHelpString (false);103 QString help = GetHelpStringInternal(false); 104 104 QByteArray ahelp = help.toLocal8Bit(); 105 105 cerr << ahelp.constData(); 106 106 wantsToExit = true; … … 276 276 } 277 277 } 278 278 279 QString MythCommandLineParser::GetHelpStringInternal(bool with_header) const 280 { 281 if (helpFunction) 282 { 283 helpFunction(*this); 284 return ""; 285 } 286 287 return GetHelpString(with_header); 288 } 289 279 290 QString MythCommandLineParser::GetHelpString(bool with_header) const 280 291 { 281 292 QString str; -
programs/mythfrontend/main.cpp
1119 1119 kCLPDisplay | 1120 1120 #endif // USING_X11 1121 1121 kCLPExtra | 1122 kCLPGeometry); 1122 kCLPGeometry | 1123 kCLPHelp, 1124 ShowUsage); 1123 1125 1126 // This will catch any help lines (e.g. --h) and display them 1124 1127 for (int argpos = 1; argpos < argc; ++argpos) 1125 1128 { 1126 1129 if (cmdline.PreParse(argc, argv, argpos, cmdline_err)) … … 1160 1163 1161 1164 for (int argpos = 1; argpos < a.argc(); ++argpos) 1162 1165 { 1163 if (!strcmp(a.argv()[argpos],"-h") || 1164 !strcmp(a.argv()[argpos],"--help") || 1165 !strcmp(a.argv()[argpos],"--usage")) 1166 { 1167 ShowUsage(cmdline); 1168 return FRONTEND_EXIT_OK; 1169 } 1170 else if (!strcmp(a.argv()[argpos],"--prompt") || 1166 if (!strcmp(a.argv()[argpos],"--prompt") || 1171 1167 !strcmp(a.argv()[argpos],"-p" )) 1172 1168 { 1173 1169 bPromptForBackend = true; … … 1307 1303 !strcmp(a.argv()[argpos],"--help") || 1308 1304 !strcmp(a.argv()[argpos],"--usage"))) 1309 1305 cerr << "Invalid argument: " << a.argv()[argpos] << endl; 1310 ShowUsage(cmdline);1311 return FRONTEND_EXIT_INVALID_CMDLINE;1306 ShowUsage(cmdline); 1307 return FRONTEND_EXIT_INVALID_CMDLINE; 1312 1308 } 1313 1309 } 1314 1310 settingsOverride = cmdline.GetSettingsOverride(); -
programs/mythwelcome/main.cpp
77 77 MythCommandLineParser cmdline( 78 78 kCLPOverrideSettingsFile | 79 79 kCLPOverrideSettings | 80 kCLPQueryVersion); 80 kCLPQueryVersion | 81 kCLPHelp, 82 showUsage); 81 83 82 84 for (int argpos = 0; argpos < argc; ++argpos) 83 85 {