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/sysrepo_access.cpp b/src/sysrepo_access.cpp
index 2d1a1b4..7115ad7 100644
--- a/src/sysrepo_access.cpp
+++ b/src/sysrepo_access.cpp
@@ -130,12 +130,23 @@
 
 SysrepoAccess::~SysrepoAccess() = default;
 
-SysrepoAccess::SysrepoAccess(const std::string& appname)
+sr_datastore_t toSrDatastore(Datastore datastore)
+{
+    switch (datastore) {
+    case Datastore::Running:
+        return SR_DS_RUNNING;
+    case Datastore::Startup:
+        return SR_DS_STARTUP;
+    }
+    __builtin_unreachable();
+}
+
+SysrepoAccess::SysrepoAccess(const std::string& appname, const Datastore datastore)
     : m_connection(new sysrepo::Connection(appname.c_str()))
     , m_schema(new YangSchema())
 {
     try {
-        m_session = std::make_shared<sysrepo::Session>(m_connection);
+        m_session = std::make_shared<sysrepo::Session>(m_connection, toSrDatastore(datastore));
     } catch (sysrepo::sysrepo_exception& ex) {
         reportErrors();
     }
@@ -267,17 +278,6 @@
     return res;
 }
 
-sr_datastore_t toSrDatastore(Datastore datastore)
-{
-    switch (datastore) {
-    case Datastore::Running:
-        return SR_DS_RUNNING;
-    case Datastore::Startup:
-        return SR_DS_STARTUP;
-    }
-    __builtin_unreachable();
-}
-
 void SysrepoAccess::copyConfig(const Datastore source, const Datastore destination)
 {
     m_session->copy_config(nullptr, toSrDatastore(source), toSrDatastore(destination));