From 5c5e49c03e86a99bea855ee204f4ddf7d525ca64 Mon Sep 17 00:00:00 2001 From: denes Date: Thu, 7 Feb 2019 15:20:30 +0100 Subject: [PATCH] Added licence in the main.cpp header and updated argParse parameters the rest is just mere programming... --- .gitignore | 1 + CMakeLists.txt | 3 ++- main.cpp | 35 +++++++++++++++++++++++++++++++++-- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index a44462f..df1208c 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ install_manifest.txt compile_commands.json CTestTestfile.cmake +webfish diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f421be..42ca363 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,4 +13,5 @@ include_directories(cpp_utils/lib/) add_executable (webfish main.cpp) -target_link_libraries(CppUtils) +target_link_libraries(webfish CppUtils) + diff --git a/main.cpp b/main.cpp index dc7156f..9886d1d 100644 --- a/main.cpp +++ b/main.cpp @@ -1,17 +1,48 @@ +/* +Copyright 2018 Denes Matetelki + +This file is part of webfish. + +webfish is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License v3 as published by the Free +Software Foundation. + +webfish is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License v3 for +more details. + +You should have received a copy of the GNU General Public License v3 along +with webfish. If not, see +https://www.gnu.org/licenses/gpl-3.0.html. +*/ + #include #include int main(int argc, char* argv[]) { - ArgParse a(""); + ArgParse a("A simple HTTP server that bites on Gitea webhooks.", + "Homepage: http://matetelki.eu:3000/denes/webfish\n" \ + "Author: Denes Matetelki " + ); + a.addArgument("-p", "Listenning port (default is 5050)", + ArgParse::ValueType::INT); + a.addArgument("-f", "File to execute on receiving a POST message", + ArgParse::ValueType::STRING, + ArgParse::Required::REQUIRED, + ArgParse::Required::REQUIRED); + try { a.parseArgs(argc, argv); } catch(...) { - std::cerr << a.usage(); + std::cerr << a.usage() << std::endl; return EXIT_FAILURE; } + if (a.foundArg("-h")) + std::cout << a.usage() << std::endl; return EXIT_SUCCESS; }