poafloc

poafloc - Parser Of Arguments For Lines Of Commands
git clone git://git.dimitrijedobrota.com/poafloc.git
Log | Files | Refs | README | LICENSE

commit 20708150e7984fdb32d04d08c8b366f1e0eada5b
parent 6742bf3cc7de1fc167e7ee1036188ee7090fcfa1
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Tue, 11 Jun 2024 01:51:38 +0200

No need for two library versions, one will suffice

Diffstat:
MCMakeLists.txt | 2+-
Mdemo/CMakeLists.txt | 2+-
Mdemo/main.cpp | 4++--
Minclude/args.h | 14+++++++-------
Msrc/CMakeLists.txt | 19++-----------------
5 files changed, 13 insertions(+), 28 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt @@ -3,7 +3,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) project( args - VERSION 0.0.2 + VERSION 0.0.3 DESCRIPTION "Command Line Argument Parser" LANGUAGES CXX C ) diff --git a/demo/CMakeLists.txt b/demo/CMakeLists.txt @@ -10,7 +10,7 @@ set_target_properties(demo PROPERTIES ) add_executable(cdemo main.c) -target_link_libraries(cdemo PRIVATE cargs) +target_link_libraries(cdemo PRIVATE args) set_target_properties(cdemo PROPERTIES LANGUAGE C) set_target_properties(cdemo PROPERTIES VERSION ${PROJECT_VERSION} diff --git a/demo/main.cpp b/demo/main.cpp @@ -8,8 +8,8 @@ using namespace args; void error(const std::string &message) { std::cerr << message << std::endl; } struct arguments_t { - const char *output_file = ""; - const char *input_file = ""; + const char *output_file = "stdout"; + const char *input_file = "stdin"; bool debug = 0; bool hex = 0; diff --git a/include/args.h b/include/args.h @@ -25,21 +25,21 @@ typedef struct __Parser args_parser; #endif typedef struct { - const char *name; + char const *name; int key; - const char *arg; + char const *arg; int flags; - const char *message; + char const *message; int group; } args_option_t; typedef int (*args_parse_f)(int key, const char *arg, args_parser *parser); typedef struct { - const args_option_t *options; - const args_parse_f parse; - const char *doc; - const char *message; + args_option_t const *options; + args_parse_f parse; + char const *doc; + char const *message; } args_argp_t; enum ENUM_OPTION { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt @@ -1,5 +1,6 @@ -add_library(args STATIC args.cpp help.cpp trie.cpp) +add_library(args STATIC args.cpp help.cpp trie.cpp c_bindings.cpp) target_include_directories(args PUBLIC ../include) +target_compile_definitions(args PRIVATE WITH_C_BINDINGS) set_target_properties(args PROPERTIES LINKER_LANGUAGE CXX) set_target_properties(args PROPERTIES @@ -12,19 +13,3 @@ install(TARGETS args LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include ) - -add_library(cargs STATIC c_bindings.cpp args.cpp help.cpp trie.cpp) -target_compile_definitions(cargs PRIVATE WITH_C_BINDINGS) -target_include_directories(cargs PUBLIC ../include) -set_target_properties(cargs PROPERTIES LINKER_LANGUAGE CXX) - -set_target_properties(cargs PROPERTIES - VERSION ${PROJECT_VERSION} - SOVERSION ${PROJECT_VERSION_MAJOR} - PUBLIC_HEADER ../include/args.h -) - -install(TARGETS cargs - LIBRARY DESTINATION lib - PUBLIC_HEADER DESTINATION include -)