From a1127b3139847684015ca64e1bcc25f7485a360d Mon Sep 17 00:00:00 2001 From: acetone Date: Thu, 27 May 2021 09:50:00 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B?= =?UTF-8?q?=D1=85=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=B8=20=D0=B2=D1=8B=D0=B4=D0=B0=D1=87=D0=B0=20=D0=BE?= =?UTF-8?q?=D1=88=D0=B8=D0=B1=D0=BA=D0=B8,=20=D0=B5=D1=81=D0=BB=D0=B8=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D0=B0=20=D0=BD=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index 8736f6d..3f774da 100644 --- a/main.cpp +++ b/main.cpp @@ -188,7 +188,7 @@ std::string search(std::string text) bool read_config() { if (!boost::filesystem::exists(config_file)) { - std::cerr << "Config not found" << std::endl; + log ("Config not found"); return false; } @@ -237,7 +237,7 @@ int write_log(std::string msg) void usage(std::string path) { - std::cout << path << " path/to/config.json" << std::endl; + std::cout << "Usage: " << path << " " << std::endl; } void make_tsc() @@ -367,12 +367,16 @@ void handler() int main(int argc, char * argv[]) { - if (argc >= 2) config_file = static_cast(argv[1]); - if (!read_config()) return 1; + if (argc > 1) config_file = static_cast(argv[1]); + else { + usage(static_cast(argv[0])); + return 1; + } + if (!read_config()) return 2; std::thread connection(make_tsc); handler(); connection.join(); - return 2; + return 3; }