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