| 87 | } |
| 88 | |
| 89 | void cli::run() |
| 90 | { |
| 91 | while( !_run_complete.canceled() ) |
| 92 | { |
| 93 | try |
| 94 | { |
| 95 | std::string line; |
| 96 | try |
| 97 | { |
| 98 | getline( _prompt.c_str(), line ); |
| 99 | } |
| 100 | catch ( const fc::eof_exception& e ) |
| 101 | { |
| 102 | break; |
| 103 | } |
| 104 | std::cout << line << "\n"; |
| 105 | line += char(EOF); |
| 106 | fc::variants args = fc::json::variants_from_string(line);; |
| 107 | if( args.size() == 0 ) |
| 108 | continue; |
| 109 | |
| 110 | const string& method = args[0].get_string(); |
| 111 | |
| 112 | auto result = receive_call( 0, method, variants( args.begin()+1,args.end() ) ); |
| 113 | auto itr = _result_formatters.find( method ); |
| 114 | if( itr == _result_formatters.end() ) |
| 115 | { |
| 116 | std::cout << fc::json::to_pretty_string( result ) << "\n"; |
| 117 | } |
| 118 | else |
| 119 | std::cout << itr->second( result, args ) << "\n"; |
| 120 | } |
| 121 | catch ( const fc::exception& e ) |
| 122 | { |
| 123 | std::cout << e.to_detail_string() << "\n"; |
| 124 | } |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | |
| 129 | char * dupstr (const char* s) { |
nothing calls this directly
no test coverage detected