# HG changeset patch # User František Kučera # Date 1534071139 -7200 # Node ID 0afc596749a17be4fabadc42f0106d9e2bfc26e1 # Parent e8be873f1eabeacda24fa05ef502957dd3461f15 move CLI.h to a common header-only library diff -r e8be873f1eab -r 0afc596749a1 CLI.h --- a/CLI.h Sun Aug 12 11:46:03 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include - -using namespace std; - -namespace relpipe { -namespace cli { - -/** - * TODO: move to relpipe-lib-cli (a common header-only library) - */ -class CLI { -public: - - CLI(int argc, char* argv[]) { - setlocale(LC_ALL, ""); - - this->argc = &argc; - this->argv = &argv; - - program = convertor.from_bytes(argv[0]); - - for (int i = 1; i < argc; i++) { - args.insert(args.end(), convertor.from_bytes(argv[i])); - } - - } - - CLI(const CLI& orig) { - } - - virtual ~CLI() { - } - - const wstring programName() { - return (const wstring) program; - } - - const vector arguments() { - return (const vector)args; - } - - static const int EXIT_CODE_SUCCESS = 0; - static const int EXIT_CODE_UNEXPECTED_ERROR = 1; - static const int EXIT_CODE_BAD_SYNTAX = 3; - static const int EXIT_CODE_UNKNOWN_COMMAND = 4; - static const int EXIT_CODE_DATA_ERROR = 5; - -private: - int* argc; - char*** argv; - wstring program; - vector args; - wstring_convert> convertor; // TODO: support also other encodings. -}; - -} -} diff -r e8be873f1eab -r 0afc596749a1 nbproject/Makefile-Debug.mk --- a/nbproject/Makefile-Debug.mk Sun Aug 12 11:46:03 2018 +0200 +++ b/nbproject/Makefile-Debug.mk Sun Aug 12 12:52:19 2018 +0200 @@ -52,7 +52,7 @@ ASFLAGS= # Link Libraries and Options -LDLIBSOPTIONS=`pkg-config --libs relpipe-lib-writer.cpp` +LDLIBSOPTIONS=`pkg-config --libs relpipe-lib-writer.cpp` `pkg-config --libs relpipe-lib-cli.cpp` # Build Targets .build-conf: ${BUILD_SUBPROJECTS} @@ -65,7 +65,7 @@ ${OBJECTDIR}/relpipe-in-fstab.o: relpipe-in-fstab.cpp ${MKDIR} -p ${OBJECTDIR} ${RM} "$@.d" - $(COMPILE.cc) -g `pkg-config --cflags relpipe-lib-writer.cpp` -std=c++14 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/relpipe-in-fstab.o relpipe-in-fstab.cpp + $(COMPILE.cc) -g `pkg-config --cflags relpipe-lib-writer.cpp` `pkg-config --cflags relpipe-lib-cli.cpp` -std=c++14 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/relpipe-in-fstab.o relpipe-in-fstab.cpp # Subprojects .build-subprojects: diff -r e8be873f1eab -r 0afc596749a1 nbproject/Makefile-Release.mk --- a/nbproject/Makefile-Release.mk Sun Aug 12 11:46:03 2018 +0200 +++ b/nbproject/Makefile-Release.mk Sun Aug 12 12:52:19 2018 +0200 @@ -52,7 +52,7 @@ ASFLAGS= # Link Libraries and Options -LDLIBSOPTIONS=`pkg-config --libs relpipe-lib-writer.cpp` +LDLIBSOPTIONS=`pkg-config --libs relpipe-lib-writer.cpp` `pkg-config --libs relpipe-lib-cli.cpp` # Build Targets .build-conf: ${BUILD_SUBPROJECTS} @@ -65,7 +65,7 @@ ${OBJECTDIR}/relpipe-in-fstab.o: relpipe-in-fstab.cpp ${MKDIR} -p ${OBJECTDIR} ${RM} "$@.d" - $(COMPILE.cc) -O2 `pkg-config --cflags relpipe-lib-writer.cpp` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/relpipe-in-fstab.o relpipe-in-fstab.cpp + $(COMPILE.cc) -O2 `pkg-config --cflags relpipe-lib-writer.cpp` `pkg-config --cflags relpipe-lib-cli.cpp` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/relpipe-in-fstab.o relpipe-in-fstab.cpp # Subprojects .build-subprojects: diff -r e8be873f1eab -r 0afc596749a1 nbproject/configurations.xml --- a/nbproject/configurations.xml Sun Aug 12 11:46:03 2018 +0200 +++ b/nbproject/configurations.xml Sun Aug 12 12:52:19 2018 +0200 @@ -4,7 +4,6 @@ - CLI.h `pkg-config --libs relpipe-lib-writer.cpp` + `pkg-config --libs relpipe-lib-cli.cpp` - - @@ -73,11 +71,10 @@ `pkg-config --libs relpipe-lib-writer.cpp` + `pkg-config --libs relpipe-lib-cli.cpp` - - diff -r e8be873f1eab -r 0afc596749a1 nbproject/project.xml --- a/nbproject/project.xml Sun Aug 12 11:46:03 2018 +0200 +++ b/nbproject/project.xml Sun Aug 12 12:52:19 2018 +0200 @@ -6,7 +6,7 @@ relpipe-in-fstab.cpp cpp - h + UTF-8 diff -r e8be873f1eab -r 0afc596749a1 relpipe-in-fstab.cpp --- a/relpipe-in-fstab.cpp Sun Aug 12 11:46:03 2018 +0200 +++ b/relpipe-in-fstab.cpp Sun Aug 12 12:52:19 2018 +0200 @@ -10,7 +10,7 @@ #include #include -#include "CLI.h" +#include using namespace relpipe::cli; using namespace relpipe::writer;