| 269 | |
| 270 | |
| 271 | void parse_and_execute_interactive_command(string command, |
| 272 | fc::istream_ptr argument_stream) |
| 273 | { |
| 274 | if (command.size() == 0) |
| 275 | return; |
| 276 | if (command == "enable_raw") |
| 277 | { |
| 278 | show_raw_output = true; |
| 279 | return; |
| 280 | } |
| 281 | else if (command == "disable_raw") |
| 282 | { |
| 283 | show_raw_output = false; |
| 284 | return; |
| 285 | } |
| 286 | |
| 287 | BufferedIstreamWithEotHack buffered_argument_stream(argument_stream); |
| 288 | |
| 289 | bool command_is_valid = false; |
| 290 | fc::variants arguments; |
| 291 | try |
| 292 | { |
| 293 | arguments = _self->parse_interactive_command(buffered_argument_stream, command); |
| 294 | // NOTE: arguments here have not been filtered for private keys or passwords |
| 295 | // ilog( "command: ${c} ${a}", ("c",command)("a",arguments) ); |
| 296 | command_is_valid = true; |
| 297 | } |
| 298 | catch (const rpc::unknown_method&) |
| 299 | { |
| 300 | if (command.size()) |
| 301 | *_out << "Error: invalid command \"" << command << "\"\n"; |
| 302 | } |
| 303 | catch (const thinkyoung::cli::abort_cli_command&) |
| 304 | { |
| 305 | throw; |
| 306 | } |
| 307 | catch (const fc::exception& e) |
| 308 | { |
| 309 | *_out << e.to_detail_string() << "\n"; |
| 310 | *_out << "Error parsing command \"" << command << "\": " << e.to_string() << "\n"; |
| 311 | arguments = fc::variants{ command }; |
| 312 | edump((e.to_detail_string())); |
| 313 | auto usage = _client->help(command); //_rpc_server->direct_invoke_method("help", arguments).as_string(); |
| 314 | *_out << usage << "\n"; |
| 315 | } |
| 316 | |
| 317 | //if command is valid, go ahead and execute it |
| 318 | if (command_is_valid) |
| 319 | { |
| 320 | try |
| 321 | { |
| 322 | fc::variant result = _self->execute_interactive_command(command, arguments); |
| 323 | _self->format_and_print_result(command, arguments, result); |
| 324 | } |
| 325 | catch (const thinkyoung::cli::abort_cli_command&) |
| 326 | { |
| 327 | throw; |
| 328 | } |
no test coverage detected