From 6ca977ec54f0feaa520c5c090bf40531caf90a0c Mon Sep 17 00:00:00 2001 From: fantasy-peak <1356346239@qq.com> Date: Mon, 2 Sep 2024 13:15:34 +0800 Subject: [PATCH] Improve formatting --- src/main.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index f9fc05b..45a570f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -220,7 +220,7 @@ void formatCode(const std::string& file, const std::string& content) { char buffer[2048] = {}; std::string result; char* clang_format_path = std::getenv("FRPC_CLANG_FORMAT"); - auto command = fmt::format("{} {}", clang_format_path ? clang_format_path : "clang-format", file); + auto command = fmt::format("{} -i {}", clang_format_path ? clang_format_path : "clang-format", file); spdlog::info("start format {}", command); FILE* pipe = popen(command.c_str(), "r"); if (!pipe) { @@ -234,12 +234,7 @@ void formatCode(const std::string& file, const std::string& content) { pclose(pipe); if (result.empty()) return; - std::ofstream write(file); - if (!write.is_open()) { - spdlog::error("open {} fail", file); - return; - } - write << result; + spdlog::info("result: {}", result); } auto sort(nlohmann::json json) {