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

Method GetCommand

examples/extended/parallel/MPI/source/src/G4MPIsession.cc:101–180  ·  view source on GitHub ↗

--------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

99
100// --------------------------------------------------------------------------
101G4String G4MPIsession::GetCommand(const char* msg)
102{
103 G4String newCommand;
104 const G4String nullString = "";
105
106 // get command from shell...
107 newCommand = shell_->GetCommandLineString(msg);
108
109 G4String nC = G4StrUtil::lstrip_copy(newCommand);
110 if (nC.length() == 0) {
111 newCommand = nullString;
112 }
113 else if (nC[0] == '#') {
114 G4cout << nC << G4endl;
115 newCommand = nullString;
116 }
117 else if (nC == "ls" || nC.substr(0, 3) == "ls ") { // list commands
118 ListDirectory(nC);
119 newCommand = nullString;
120 }
121 else if (nC == "lc" || nC.substr(0, 3) == "lc ") { // ... by shell
122 shell_->ListCommand(nC.erase(0, 2));
123 newCommand = nullString;
124 }
125 else if (nC == "pwd") { // show current directory
126 G4cout << "Current Command Directory : " << GetCurrentWorkingDirectory() << G4endl;
127 newCommand = nullString;
128 }
129 else if (nC == "cwd") { // ... by shell
130 shell_->ShowCurrentDirectory();
131 newCommand = nullString;
132 }
133 else if (nC == "cd" || nC.substr(0, 3) == "cd ") { // "cd"
134 ChangeDirectoryCommand(nC);
135 shell_->SetCurrentDirectory(GetCurrentWorkingDirectory());
136 newCommand = nullString;
137 }
138 else if (nC == "help" || nC.substr(0, 5) == "help ") { // "help"
139 TerminalHelp(nC);
140 newCommand = nullString;
141 }
142 else if (nC[0] == '?') { // "show current value of a parameter"
143 ShowCurrent(nC);
144 newCommand = nullString;
145 }
146 else if (nC == "hist" || nC == "history") { // "hist/history"
147 G4int nh = ::UI->GetNumberOfHistory();
148 for (G4int i = 0; i < nh; i++) {
149 G4cout << i << ": " << ::UI->GetPreviousCommand(i) << G4endl;
150 }
151 newCommand = nullString;
152 }
153 else if (nC[0] == '!') { // "!"
154 G4String ss = nC.substr(1, nC.length() - 1);
155 G4int vl;
156 const char* tt = ss;
157 std::istringstream is(tt);
158 is >> vl;

Callers

nothing calls this directly

Calls 9

substrMethod · 0.80
ListCommandMethod · 0.80
ShowCurrentDirectoryMethod · 0.80
SetCurrentDirectoryMethod · 0.80
GetNumberOfHistoryMethod · 0.80
GetPreviousCommandMethod · 0.80
GetCommandLineStringMethod · 0.45
lengthMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected