Browse Source

XPath completion for running and candidate config

Serj Kalichev 1 year ago
parent
commit
20aac7761b
3 changed files with 19 additions and 4 deletions
  1. 3 1
      src/plugin.c
  2. 2 1
      src/private.h
  3. 14 2
      src/syms.c

+ 3 - 1
src/plugin.c

@@ -62,7 +62,9 @@ int kplugin_sysrepo_init(kcontext_t *context)
 		KSYM_USERDEFINED_PERMANENT, KSYM_UNSYNC));
 	kplugin_add_syms(plugin, ksym_new_ext("srp_prompt_edit_path", srp_prompt_edit_path,
 		KSYM_USERDEFINED_PERMANENT, KSYM_UNSYNC));
-	kplugin_add_syms(plugin, ksym_new_ext("srp_compl_xpath", srp_compl_xpath,
+	kplugin_add_syms(plugin, ksym_new_ext("srp_compl_xpath_running", srp_compl_xpath_running,
+		KSYM_USERDEFINED_PERMANENT, KSYM_UNSYNC));
+	kplugin_add_syms(plugin, ksym_new_ext("srp_compl_xpath_candidate", srp_compl_xpath_candidate,
 		KSYM_USERDEFINED_PERMANENT, KSYM_UNSYNC));
 
 	// Operations

+ 2 - 1
src/private.h

@@ -44,7 +44,8 @@ int srp_help(kcontext_t *context);
 int srp_compl_insert_to(kcontext_t *context);
 int srp_help_insert_to(kcontext_t *context);
 int srp_prompt_edit_path(kcontext_t *context);
-int srp_compl_xpath(kcontext_t *context);
+int srp_compl_xpath_running(kcontext_t *context);
+int srp_compl_xpath_candidate(kcontext_t *context);
 
 // Operations
 int srp_set(kcontext_t *context);

+ 14 - 2
src/syms.c

@@ -1128,7 +1128,7 @@ err:
 }
 
 
-int srp_compl_xpath(kcontext_t *context)
+static int srp_compl_xpath(kcontext_t *context, const sr_datastore_t datastore)
 {
 	sr_conn_ctx_t *conn = NULL;
 	sr_session_ctx_t *sess = NULL;
@@ -1144,7 +1144,7 @@ int srp_compl_xpath(kcontext_t *context)
 
 	if (sr_connect(SR_CONN_DEFAULT, &conn))
 		return -1;
-	if (sr_session_start(conn, SR_DS_RUNNING, &sess)) {
+	if (sr_session_start(conn, datastore, &sess)) {
 		sr_disconnect(conn);
 		return -1;
 	}
@@ -1163,3 +1163,15 @@ int srp_compl_xpath(kcontext_t *context)
 
 	return 0;
 }
+
+
+int srp_compl_xpath_running(kcontext_t *context)
+{
+	return srp_compl_xpath(context, SR_DS_RUNNING);
+}
+
+
+int srp_compl_xpath_candidate(kcontext_t *context)
+{
+	return srp_compl_xpath(context, SR_DS_CANDIDATE);
+}