{
FG_OPTIONS_OK = 0,
FG_OPTIONS_HELP = 1,
- FG_OPTIONS_ERROR = 2
+ FG_OPTIONS_ERROR = 2,
+ FG_OPTIONS_VERBOSE_HELP = 3
};
static double
if ( (arg == "--help") || (arg == "-h") ) {
// help/usage request
return(FG_OPTIONS_HELP);
+ } else if ( (arg == "--verbose") || (arg == "-v") ) {
+ // verbose help/usage request
+ return(FG_OPTIONS_VERBOSE_HELP);
} else if ( arg == "--disable-game-mode") {
fgSetBool("/sim/startup/game-mode", false);
} else if ( arg == "--enable-game-mode" ) {
fgParseArgs (int argc, char **argv)
{
bool in_options = true;
+ bool verbose = false;
+ bool help = false;
SG_LOG(SG_GENERAL, SG_INFO, "Processing command line arguments");
in_options = false;
} else {
int result = parse_option(arg);
- if ( (result == FG_OPTIONS_HELP) ||
- (result == FG_OPTIONS_ERROR) ) {
- fgUsage();
- exit(-1);
- }
+ if ((result == FG_OPTIONS_HELP) || (result == FG_OPTIONS_ERROR))
+ help = true;
+
+ else if (result == FG_OPTIONS_VERBOSE_HELP)
+ verbose = true;
}
} else {
in_options = false;
}
}
+ if (help) {
+ fgUsage(verbose);
+ exit(0);
+ }
+
SG_LOG(SG_GENERAL, SG_INFO, "Finished command line arguments");
}
// Print usage message
void
-fgUsage ()
+fgUsage (bool verbose)
{
SGPropertyNode options_root;
SGPath opath( globals->get_fg_root() );
vector<SGPropertyNode_ptr>section = options->getChildren("section");
for (unsigned int j = 0; j < section.size(); j++) {
-
- SGPropertyNode *name = section[j]->getNode("name");
- if (name) {
- cout << endl << name->getStringValue() << ":" << endl;
- }
+ string msg = "";
vector<SGPropertyNode_ptr>option = section[j]->getChildren("option");
for (unsigned int k = 0; k < option.size(); k++) {
SGPropertyNode *short_name = option[k]->getNode("short");
SGPropertyNode *key = option[k]->getNode("key");
SGPropertyNode *arg = option[k]->getNode("arg");
+ bool brief = option[k]->getNode("brief");
- if (name) {
+ if ((brief || verbose) && name) {
string tmp = name->getStringValue();
if (key){
} else {
snprintf(cstr, 96, "\n --%s\n%32c", tmp.c_str(), ' ');
}
- string msg = cstr;
+ msg += cstr;
SGPropertyNode *desc = option[k]->getNode("description");
if (desc) {
msg += desc->getStringValue();
desc->getStringValue());
msg += cstr;
}
+ msg += '\n';
}
- cout << msg << endl;
}
}
+
+ SGPropertyNode *name = section[j]->getNode("name");
+ if (!msg.empty() && name) {
+ cout << endl << name->getStringValue() << ":" << endl;
+ cout << msg;
+ msg.erase();
+ }
+ }
+
+ if ( !verbose ) {
+ cout << endl;
+ cout << "For a complete list of options use --help --verbose" << endl;
}
}