Public Member Functions | |
BLCMDhelp () | |
G4String | commandName () |
int | command (BLArgumentVector &argv, BLArgumentMap &namedArgs) |
BLCMDhelp::BLCMDhelp | ( | ) |
References BLCMDTYPE_HELP, BLCommand::registerCommand(), BLCommand::setDescription(), and BLCommand::setSynopsis().
00044 { 00045 registerCommand(BLCMDTYPE_HELP); 00046 setSynopsis("provides interactive help."); 00047 setDescription("help with no arguments lists all commands.\n" 00048 "'help command' gives more detailed help on that command.\n" 00049 "'help *' gives detailed help for all commands.\n" 00050 "If the first argument is -exit\n" 00051 "the program will exit after printing the help."); 00052 }
G4String BLCMDhelp::commandName | ( | ) | [inline, virtual] |
int BLCMDhelp::command | ( | BLArgumentVector & | argv, | |
BLArgumentMap & | namedArgs | |||
) | [virtual] |
Implements BLCommand.
References BLCMDTYPE_AUX, BLCMDTYPE_BEAM, BLCMDTYPE_CONTROL, BLCMDTYPE_CUTS, BLCMDTYPE_DATA, BLCMDTYPE_ELEMENT, BLCMDTYPE_HELP, BLCMDTYPE_LAYOUT, BLCMDTYPE_OTHER, BLCMDTYPE_PLACE, g4bl_exit(), BLParam::getHelpText(), BLManager::getObject(), BLCommand::mapCommand, and Param.
00055 { 00056 bool exit = (argv.size() > 0 && argv[0] == "-exit"); 00057 if(exit) argv.erase(argv.begin()); 00058 00059 if(argv.size() == 0) { 00060 for(int j=0; j<=(int)BLCMDTYPE_OTHER; ++j) { 00061 switch((BLCmdType)j) { 00062 case BLCMDTYPE_HELP: 00063 printf("\nThe help command:\n"); 00064 break; 00065 case BLCMDTYPE_CONTROL: 00066 printf("\nProgram control commands:\n"); 00067 break; 00068 case BLCMDTYPE_LAYOUT: 00069 printf("\nCenterline layout commands:\n"); 00070 break; 00071 case BLCMDTYPE_BEAM: 00072 printf("\nBeam definition commands:\n"); 00073 break; 00074 case BLCMDTYPE_AUX: 00075 printf("\nAuxiliary definition commands:\n"); 00076 break; 00077 case BLCMDTYPE_CUTS: 00078 printf("\nTrack and Event cuts:\n"); 00079 break; 00080 case BLCMDTYPE_ELEMENT: 00081 printf("\nBeamline element definition commands:\n"); 00082 break; 00083 case BLCMDTYPE_PLACE: 00084 printf("\nThe place command:\n"); 00085 break; 00086 case BLCMDTYPE_DATA: 00087 printf("\nData output commands:\n"); 00088 break; 00089 case BLCMDTYPE_OTHER: 00090 printf("\nOther commands:\n"); 00091 break; 00092 } 00093 std::map<G4String,BLCommand*>::iterator i; 00094 for(i=(*BLCommand::mapCommand).begin(); 00095 i != (*BLCommand::mapCommand).end(); ++i) { 00096 if((BLCmdType)j == i->second->getCmdType()) { 00097 printf(" "); 00098 i->second->help(false); 00099 } 00100 } 00101 } 00102 printf("\nProgram control Parameters:\n%s", 00103 Param.getHelpText().c_str()); 00104 printf("steppingFormat is a space- or comma-separated list of items:\n%s\n\n", 00105 BLManager::getObject()->getFormatHelp().c_str()); 00106 } else if(argv[0] == "*") { 00107 std::map<G4String,BLCommand*>::iterator i; 00108 for(i=(*BLCommand::mapCommand).begin(); 00109 i != (*BLCommand::mapCommand).end(); ++i) { 00110 i->second->help(true); 00111 printf("\n"); 00112 } 00113 } else { 00114 for(unsigned i=0; i<argv.size(); ++i) { 00115 if((*BLCommand::mapCommand).count(argv[i]) == 0) { 00116 printf("Command '%s' not found.\n", 00117 argv[i].c_str()); 00118 } else { 00119 (*BLCommand::mapCommand)[argv[i]]->help(true); 00120 } 00121 } 00122 } 00123 00124 if(exit) { 00125 fflush(stdout); 00126 extern void g4bl_exit(int); 00127 g4bl_exit(0); 00128 } 00129 00130 return 0; 00131 }