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