MCPcopy Create free account
hub / github.com/ChaiScript/ChaiScript / get_next_command

Function get_next_command

src/main.cpp:189–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187}
188
189std::string get_next_command() {
190 std::string retval("quit");
191 if ( ! std::cin.eof() ) {
192 char *input_raw = readline("eval> ");
193 if ( input_raw != nullptr ) {
194 add_history(input_raw);
195
196 std::string val(input_raw);
197 size_t pos = val.find_first_not_of("\t \n");
198 if (pos != std::string::npos)
199 {
200 val.erase(0, pos);
201 }
202 pos = val.find_last_not_of("\t \n");
203 if (pos != std::string::npos)
204 {
205 val.erase(pos+1, std::string::npos);
206 }
207
208 retval = val;
209
210 ::free(input_raw);
211 }
212 }
213 if( retval == "quit"
214 || retval == "exit"
215 || retval == "help"
216 || retval == "version")
217 {
218 retval += "(0)";
219 }
220 return retval;
221}
222
223// We have to wrap exit with our own because Clang has a hard time with
224// function pointers to functions with special attributes (system exit being marked NORETURN)

Callers 1

interactiveFunction · 0.70

Calls 2

readlineFunction · 0.70
add_historyFunction · 0.70

Tested by

no test coverage detected