yang-cli: Allow editing ops data

Change-Id: Ica85cacac7fed0b052687b7262a76411a03e80f1
diff --git a/src/cli.cpp b/src/cli.cpp
index 53670d0..63ef4c3 100644
--- a/src/cli.cpp
+++ b/src/cli.cpp
@@ -36,14 +36,15 @@
   will be used to find a schema for that module.
 
 Usage:
-  yang-cli [-s <search_dir>] [-e enable_features]... [-i data_file]... <schema_file_or_module_name>...
+  yang-cli [--configonly] [-s <search_dir>] [-e enable_features]... [-i data_file]... <schema_file_or_module_name>...
   yang-cli (-h | --help)
   yang-cli --version
 
 Options:
   -s <search_dir>       Set search for schema lookup
   -e <enable_features>  Feature to enable after modules are loaded. This option can be supplied more than once. Format: <module_name>:<feature>
-  -i <data_file>        File to import data from)";
+  -i <data_file>        File to import data from
+  --configonly          Disable editing of operational data)";
 #else
 #error "Unknown CLI backend"
 #endif
@@ -57,6 +58,7 @@
                                true,
                                PROGRAM_NAME " " NETCONF_CLI_VERSION,
                                true);
+    WritableOps writableOps = WritableOps::No;
 
 #if defined(SYSREPO_CLI)
     auto datastoreType = Datastore::Running;
@@ -74,6 +76,12 @@
     std::cout << "Connected to sysrepo [datastore: " << (datastoreType == Datastore::Startup ? "startup" : "running") << "]" << std::endl;
 #elif defined(YANG_CLI)
     YangAccess datastore;
+    if (args["--configonly"].asBool()) {
+        writableOps = WritableOps::No;
+    } else {
+        writableOps = WritableOps::Yes;
+        std::cout << "ops is writable" << std::endl;
+    }
     if (const auto& search_dir = args["-s"]) {
         datastore.addSchemaDir(search_dir.asString());
     }
@@ -116,7 +124,7 @@
 #endif
 
     auto dataQuery = std::make_shared<DataQuery>(datastore);
-    Parser parser(datastore.schema(), dataQuery);
+    Parser parser(datastore.schema(), writableOps, dataQuery);
 
     using replxx::Replxx;