| 66 | } |
| 67 | |
| 68 | int main(int argc, const char* argv[]) { |
| 69 | if (argc < 4) { |
| 70 | const auto help_msg = "please pass all necessary arguments\n\ |
| 71 | argv[1] - the file to process\n\ |
| 72 | argv[2] - the character to replace\n\ |
| 73 | argv[3] - the character to replace with"; |
| 74 | |
| 75 | std::cerr << help_msg << std::endl; |
| 76 | return -1; |
| 77 | } |
| 78 | |
| 79 | if (std::strlen(argv[2]) != 1 || std::strlen(argv[3]) != 1) { |
| 80 | std::cerr << "argv[2] and argv[3] must be one character only" << std::endl; |
| 81 | return -1; |
| 82 | } |
| 83 | |
| 84 | const auto file_path = std::string(argv[1]); |
| 85 | const auto from_char = argv[2][0]; |
| 86 | const auto to_char = argv[3][0]; |
| 87 | |
| 88 | concurrencpp::runtime runtime; |
| 89 | |
| 90 | try { |
| 91 | replace_chars_in_file(runtime.background_executor(), runtime.thread_pool_executor(), file_path, from_char, to_char).get(); |
| 92 | } catch (const std::exception& e) { |
| 93 | std::cerr << e.what() << std::endl; |
| 94 | } |
| 95 | |
| 96 | return 0; |
| 97 | } |
nothing calls this directly
no test coverage detected