# HG changeset patch # User František Kučera # Date 1534071378 -7200 # Node ID 22f493401ac00483f4aad61f5284b90d8d2873cb # Parent 9e543fd0254c650744d117b3fb819d28ea8cfb31 move CLI.h to a common header-only library diff -r 9e543fd0254c -r 22f493401ac0 CLI.h --- a/CLI.h Thu Aug 09 22:58:38 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 9e543fd0254c -r 22f493401ac0 RelpipeCLIException.h --- a/RelpipeCLIException.h Thu Aug 09 22:58:38 2018 +0200 +++ b/RelpipeCLIException.h Sun Aug 12 12:56:18 2018 +0200 @@ -2,7 +2,7 @@ #include -#include "CLI.h" +#include using namespace std; diff -r 9e543fd0254c -r 22f493401ac0 StdInCommand.h --- a/StdInCommand.h Thu Aug 09 22:58:38 2018 +0200 +++ b/StdInCommand.h Sun Aug 12 12:56:18 2018 +0200 @@ -10,8 +10,9 @@ #include #include +#include + #include "Command.h" -#include "CLI.h" #include "RelpipeCLIException.h" namespace relpipe { diff -r 9e543fd0254c -r 22f493401ac0 nbproject/Makefile-Debug.mk --- a/nbproject/Makefile-Debug.mk Thu Aug 09 22:58:38 2018 +0200 +++ b/nbproject/Makefile-Debug.mk Sun Aug 12 12:56:18 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-cli.o: relpipe-in-cli.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-cli.o relpipe-in-cli.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-cli.o relpipe-in-cli.cpp # Subprojects .build-subprojects: diff -r 9e543fd0254c -r 22f493401ac0 nbproject/Makefile-Release.mk --- a/nbproject/Makefile-Release.mk Thu Aug 09 22:58:38 2018 +0200 +++ b/nbproject/Makefile-Release.mk Sun Aug 12 12:56:18 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-cli.o: relpipe-in-cli.cpp ${MKDIR} -p ${OBJECTDIR} ${RM} "$@.d" - $(COMPILE.cc) -O2 `pkg-config --cflags relpipe-lib-writer.cpp` -std=c++14 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/relpipe-in-cli.o relpipe-in-cli.cpp + $(COMPILE.cc) -O2 `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-cli.o relpipe-in-cli.cpp # Subprojects .build-subprojects: diff -r 9e543fd0254c -r 22f493401ac0 nbproject/configurations.xml --- a/nbproject/configurations.xml Thu Aug 09 22:58:38 2018 +0200 +++ b/nbproject/configurations.xml Sun Aug 12 12:56:18 2018 +0200 @@ -5,7 +5,6 @@ displayName="Header Files" projectFiles="true"> ArgumentsCommand.h - CLI.h Command.h DemoCommand.h RelpipeCLIException.h @@ -54,13 +53,12 @@ `pkg-config --libs relpipe-lib-writer.cpp` + `pkg-config --libs relpipe-lib-cli.cpp` - - @@ -95,13 +93,12 @@ `pkg-config --libs relpipe-lib-writer.cpp` + `pkg-config --libs relpipe-lib-cli.cpp` - - diff -r 9e543fd0254c -r 22f493401ac0 relpipe-in-cli.cpp --- a/relpipe-in-cli.cpp Thu Aug 09 22:58:38 2018 +0200 +++ b/relpipe-in-cli.cpp Sun Aug 12 12:56:18 2018 +0200 @@ -6,7 +6,8 @@ #include #include -#include "CLI.h" +#include + #include "RelpipeCLIException.h" #include "Command.h" #include "ArgumentsCommand.h"