cli: Add a command line flag to specify datastore

GCC doesn't like multiline raw string literals in macros, so I head to
get rid of the macro.

Change-Id: I1fe2c2f45f2b5700e682c229fdd182edc20e4d77
diff --git a/src/cli.cpp b/src/cli.cpp
index 7384f33..c142850 100644
--- a/src/cli.cpp
+++ b/src/cli.cpp
@@ -15,25 +15,21 @@
 #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 \
-)"
+static const auto usage = R"(CLI interface to sysrepo
+
+Usage:
+  sysrepo-cli [-d <datastore>]
+  sysrepo-cli (-h | --help)
+  sysrepo-cli --version
+
+Options:
+  -d <datastore>   can be "running" or "startup" [default: running])";
 #else
 #error "Unknown CLI backend"
 #endif
 
-
-
-
 const auto HISTORY_FILE_NAME = PROGRAM_NAME "_history";
 
-static const char usage[] = PROGRAM_DESCRIPTION;
-
-
 int main(int argc, char* argv[])
 {
     auto args = docopt::docopt(usage,
@@ -41,10 +37,21 @@
                                true,
                                PROGRAM_NAME " " NETCONF_CLI_VERSION,
                                true);
-    std::cout << "Welcome to " PROGRAM_NAME << std::endl;
 
 #if defined(SYSREPO_CLI)
-    SysrepoAccess datastore(PROGRAM_NAME);
+    auto datastoreType = Datastore::Running;
+    if (const auto& ds = args["-d"]) {
+        if (ds.asString() == "startup") {
+            datastoreType = Datastore::Startup;
+        } else if (ds.asString() == "running") {
+            datastoreType = Datastore::Running;
+        } else {
+            std::cerr << PROGRAM_NAME <<  ": unknown datastore: " << ds.asString() << "\n";
+            return 1;
+        }
+    }
+    SysrepoAccess datastore(PROGRAM_NAME, datastoreType);
+    std::cout << "Connected to sysrepo [datastore: " << (datastoreType == Datastore::Startup ? "startup" : "running") << "]" << std::endl;
 #else
 #error "Unknown CLI backend"
 #endif