MCPcopy Create free account
hub / github.com/Geant4/geant4 / ApplyShellCommand

Method ApplyShellCommand

source/interfaces/core/src/G4VBasicShell.cc:237–304  ·  view source on GitHub ↗

/

Source from the content-addressed store, hash-verified

235}
236/***************************************************************************/
237void G4VBasicShell::ApplyShellCommand(
238 const G4String& a_string, G4bool& exitSession, G4bool& exitPause)
239/***************************************************************************/
240/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
241{
242 G4UImanager* UI = G4UImanager::GetUIpointer();
243 if (UI == nullptr) return;
244
245 G4String command = G4StrUtil::lstrip_copy(a_string);
246
247 if (command[0] == '#') {
248 G4cout << command << G4endl;
249 }
250 else if (command == "ls" || command.substr(0, 3) == "ls ") {
251 ListDirectory(command);
252 }
253 else if (command == "pwd") {
254 G4cout << "Current Working Directory : " << GetCurrentWorkingDirectory() << G4endl;
255 }
256 else if (command == "cd" || command.substr(0, 3) == "cd ") {
257 ChangeDirectoryCommand(command);
258 }
259 else if (command == "help" || command.substr(0, 5) == "help ") {
260 TerminalHelp(command);
261 }
262 else if (command[0] == '?') {
263 ShowCurrent(command);
264 }
265 else if (command == "hist" || command == "history") {
266 G4int nh = UI->GetNumberOfHistory();
267 for (G4int i = 0; i < nh; i++) {
268 G4cout << i << ": " << UI->GetPreviousCommand(i) << G4endl;
269 }
270 }
271 else if (command[0] == '!') {
272 G4String ss = command.substr(1, command.length() - 1);
273 G4int vl;
274 const char* tt = ss;
275 std::istringstream is(tt);
276 is >> vl;
277 G4int nh = UI->GetNumberOfHistory();
278 if (vl >= 0 && vl < nh) {
279 G4String prev = UI->GetPreviousCommand(vl);
280 G4cout << prev << G4endl;
281 ExecuteCommand(ModifyToFullPathCommand(prev));
282 }
283 else {
284 G4cerr << "history " << vl << " is not found." << G4endl;
285 }
286 }
287 else if (command == "exit") {
288 if (!exitPause) { // In a secondary loop.
289 G4cout << "You are now processing RUN." << G4endl;
290 G4cout << "Please abort it using \"/run/abort\" command first" << G4endl;
291 G4cout << " and use \"continue\" command until the application" << G4endl;
292 G4cout << " becomes to Idle." << G4endl;
293 }
294 else {

Callers 3

ButtonCallbackMethod · 0.80
MainWindowProcMethod · 0.80

Calls 4

substrMethod · 0.80
GetNumberOfHistoryMethod · 0.80
GetPreviousCommandMethod · 0.80
lengthMethod · 0.45

Tested by

no test coverage detected