From 92356215efcec414f381f818418a5e8f11aea9b2 Mon Sep 17 00:00:00 2001 From: Chunting Gu Date: Mon, 5 Aug 2019 13:32:42 +0800 Subject: [PATCH] Refine help message of client examples. --- examples/client_basics.cc | 4 ++++ examples/file_upload_client.cc | 15 ++++++++------- examples/rest_book_client.cc | 13 +++++++------ 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/examples/client_basics.cc b/examples/client_basics.cc index f37180c..27b3f1b 100644 --- a/examples/client_basics.cc +++ b/examples/client_basics.cc @@ -50,6 +50,10 @@ int main() { } catch (const webcc::Error& error) { std::cerr << error << std::endl; + return 1; + } catch (const std::exception& e) { + std::cerr << e.what() << std::endl; + return 1; } return 0; diff --git a/examples/file_upload_client.cc b/examples/file_upload_client.cc index 0909d4f..d281dad 100644 --- a/examples/file_upload_client.cc +++ b/examples/file_upload_client.cc @@ -5,19 +5,20 @@ #include "webcc/client_session.h" #include "webcc/logger.h" -void Help(const char* argv0) { - std::cout << "Usage: " << argv0 << " [url]" << std::endl; +void Help() { + std::cout << "Usage:" << std::endl; + std::cout << " file_upload_client [url]" << std::endl; std::cout << "Default Url: http://httpbin.org/post" << std::endl; - std::cout << " E.g.," << std::endl; - std::cout << " " << argv0 << "E:/github/webcc/data/upload" << std::endl; - std::cout << " " << argv0 - << "E:/github/webcc/data/upload http://httpbin.org/post" + std::cout << "E.g.," << std::endl; + std::cout << " file_upload_client E:/github/webcc/data/upload" << std::endl; + std::cout << " file_upload_client E:/github/webcc/data/upload" + << " http://httpbin.org/post" << std::endl; } int main(int argc, char* argv[]) { if (argc < 2) { - Help(argv[0]); + Help(); return 1; } diff --git a/examples/rest_book_client.cc b/examples/rest_book_client.cc index 2083fc5..6ab0478 100644 --- a/examples/rest_book_client.cc +++ b/examples/rest_book_client.cc @@ -188,16 +188,17 @@ void PrintBookList(const std::list& books) { // ----------------------------------------------------------------------------- -void Help(const char* argv0) { - std::cout << "Usage: " << argv0 << " [timeout]" << std::endl; - std::cout << " E.g.," << std::endl; - std::cout << " " << argv0 << " http://localhost:8080" << std::endl; - std::cout << " " << argv0 << " http://localhost:8080 2" << std::endl; +void Help() { + std::cout << "Usage:" << std::endl; + std::cout << " rest_book_client [timeout]" << std::endl; + std::cout << "E.g.," << std::endl; + std::cout << " rest_book_client http://localhost:8080" << std::endl; + std::cout << " rest_book_client http://localhost:8080 2" << std::endl; } int main(int argc, char* argv[]) { if (argc < 2) { - Help(argv[0]); + Help(); return 1; }