Allow configuring CLI backend

Change-Id: I5c0ec73b72c5b4ae96bf3f60f99692cbd1678b03
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 28b0163..1a4aeb6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -136,19 +136,20 @@
 link_directories(${SYSREPO_LIBRARY_DIRS})
 target_include_directories(sysreposubscription SYSTEM PRIVATE ${SYSREPO_INCLUDE_DIRS})
 
-add_executable(netconf-cli
-    src/main.cpp
+add_executable(sysrepo-cli
+    src/cli.cpp
     )
-target_include_directories(netconf-cli PRIVATE ${REPLXX_PATH})
-target_link_libraries(netconf-cli netconfaccess sysrepoaccess yangschema docopt parser ${REPLXX_LIBRARY})
+target_compile_definitions(sysrepo-cli PRIVATE SYSREPO_CLI)
+target_include_directories(sysrepo-cli PRIVATE ${REPLXX_PATH})
+target_link_libraries(sysrepo-cli sysrepoaccess yangschema docopt parser ${REPLXX_LIBRARY})
 if(CMAKE_CXX_FLAGS MATCHES "-stdlib=libc\\+\\+")
-    target_link_libraries(netconf-cli c++experimental)
+    target_link_libraries(sysrepo-cli c++experimental)
 else()
-    target_link_libraries(netconf-cli stdc++fs)
+    target_link_libraries(sysrepo-cli stdc++fs)
 endif()
 
-add_dependencies(netconf-cli target-NETCONF_CLI_VERSION)
-target_include_directories(netconf-cli PRIVATE ${PROJECT_BINARY_DIR})
+add_dependencies(sysrepo-cli target-NETCONF_CLI_VERSION)
+target_include_directories(sysrepo-cli PRIVATE ${PROJECT_BINARY_DIR})
 
 include(CTest)
 if(BUILD_TESTING)
@@ -347,5 +348,5 @@
 endif()
 
 install(TARGETS
-    netconf-cli
+    sysrepo-cli
     RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/)
diff --git a/src/main.cpp b/src/cli.cpp
similarity index 84%
rename from src/main.cpp
rename to src/cli.cpp
index fd064ba..7384f33 100644
--- a/src/main.cpp
+++ b/src/cli.cpp
@@ -12,18 +12,26 @@
 #include <sstream>
 #include "NETCONF_CLI_VERSION.h"
 #include "interpreter.hpp"
+#if defined(SYSREPO_CLI)
 #include "sysrepo_access.hpp"
+#define PROGRAM_NAME "sysrepo-cli"
+#define PROGRAM_DESCRIPTION R"(CLI interface to sysrepo \
+\
+Usage: \
+  sysrepo-cli \
+  sysrepo-cli (-h | --help) \
+  sysrepo-cli --version \
+)"
+#else
+#error "Unknown CLI backend"
+#endif
 
-const auto HISTORY_FILE_NAME = "netconf-cli_history";
 
-static const char usage[] =
-    R"(CLI interface to remote NETCONF hosts
 
-Usage:
-  netconf-cli
-  netconf-cli (-h | --help)
-  netconf-cli --version
-)";
+
+const auto HISTORY_FILE_NAME = PROGRAM_NAME "_history";
+
+static const char usage[] = PROGRAM_DESCRIPTION;
 
 
 int main(int argc, char* argv[])
@@ -31,11 +39,16 @@
     auto args = docopt::docopt(usage,
                                {argv + 1, argv + argc},
                                true,
-                               "netconf-cli " NETCONF_CLI_VERSION,
+                               PROGRAM_NAME " " NETCONF_CLI_VERSION,
                                true);
-    std::cout << "Welcome to netconf-cli" << std::endl;
+    std::cout << "Welcome to " PROGRAM_NAME << std::endl;
 
-    SysrepoAccess datastore("netconf-cli");
+#if defined(SYSREPO_CLI)
+    SysrepoAccess datastore(PROGRAM_NAME);
+#else
+#error "Unknown CLI backend"
+#endif
+
     auto dataQuery = std::make_shared<DataQuery>(datastore);
     Parser parser(datastore.schema(), dataQuery);