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