Ver código fonte

completion: Add existing_nodes_only flag to pline_print_completions()

Serj Kalichev 11 meses atrás
pai
commit
e492e360d9
5 arquivos alterados com 24 adições e 21 exclusões
  1. 4 3
      bin/Makefile.am
  2. 1 1
      bin/ytree.c
  3. 2 1
      src/klish_plugin_sysrepo.h
  4. 2 1
      src/pline.c
  5. 15 15
      src/syms.c

+ 4 - 3
bin/Makefile.am

@@ -3,9 +3,10 @@ bin_PROGRAMS += \
 	bin/srp_load
 
 bin_ytree_SOURCES = \
-	bin/ytree.c \
-	src/pline.c \
-	src/kly.c
+	bin/ytree.c
+
+bin_ytree_LDADD = \
+	libklish-plugin-sysrepo.la
 
 bin_srp_load_SOURCES = \
 	bin/srp_load.c

+ 1 - 1
bin/ytree.c

@@ -41,7 +41,7 @@ int main(int argc, char **argv)
 	pline = pline_parse(sess, args, &opts);
 	faux_argv_free(args);
 	pline_debug(pline);
-	pline_print_completions(pline, BOOL_TRUE, PT_COMPL_ALL);
+	pline_print_completions(pline, BOOL_TRUE, PT_COMPL_ALL, BOOL_FALSE);
 	pline_free(pline);
 
 	ret = 0;

+ 2 - 1
src/klish_plugin_sysrepo.h

@@ -190,7 +190,8 @@ pexpr_t *pline_current_expr(pline_t *pline);
 void pline_free(pline_t *pline);
 
 void pline_debug(pline_t *pline);
-void pline_print_completions(const pline_t *pline, bool_t help, pt_e enabled_types);
+void pline_print_completions(const pline_t *pline, bool_t help,
+	pt_e enabled_types, bool_t existing_nodes_only);
 
 size_t num_of_keys(const struct lysc_node *node);
 

+ 2 - 1
src/pline.c

@@ -1291,7 +1291,8 @@ static void pline_print_type_help(const struct lysc_node *node,
 }
 
 
-void pline_print_completions(const pline_t *pline, bool_t help, pt_e enabled_types)
+void pline_print_completions(const pline_t *pline, bool_t help,
+	pt_e enabled_types, bool_t existing_nodes_only)
 {
 	faux_list_node_t *iter = NULL;
 	pcompl_t *pcompl = NULL;

+ 15 - 15
src/syms.c

@@ -98,7 +98,7 @@ static faux_argv_t *param2argv(const faux_argv_t *cur_path,
 // completed). kpargv's list don't contain candidate but only already parsed
 // words.
 static int srp_compl_or_help(kcontext_t *context, bool_t help,
-	pt_e enabled_ptypes, bool_t use_cur_path)
+	pt_e enabled_ptypes, bool_t use_cur_path, bool_t existing_nodes_only)
 {
 	faux_argv_t *args = NULL;
 	pline_t *pline = NULL;
@@ -116,7 +116,7 @@ static int srp_compl_or_help(kcontext_t *context, bool_t help,
 	args = param2argv(cur_path, kcontext_parent_pargv(context), entry_name);
 	pline = pline_parse(sess, args, srp_udata_opts(context));
 	faux_argv_free(args);
-	pline_print_completions(pline, help, enabled_ptypes);
+	pline_print_completions(pline, help, enabled_ptypes, existing_nodes_only);
 	pline_free(pline);
 
 	return 0;
@@ -125,73 +125,73 @@ static int srp_compl_or_help(kcontext_t *context, bool_t help,
 
 int srp_compl(kcontext_t *context)
 {
-	return srp_compl_or_help(context, BOOL_FALSE, PT_COMPL_ALL, BOOL_TRUE);
+	return srp_compl_or_help(context, BOOL_FALSE, PT_COMPL_ALL, BOOL_TRUE, BOOL_FALSE);
 }
 
 
 int srp_help(kcontext_t *context)
 {
-	return srp_compl_or_help(context, BOOL_TRUE, PT_COMPL_ALL, BOOL_TRUE);
+	return srp_compl_or_help(context, BOOL_TRUE, PT_COMPL_ALL, BOOL_TRUE, BOOL_FALSE);
 }
 
 
 int srp_compl_set(kcontext_t *context)
 {
-	return srp_compl_or_help(context, BOOL_FALSE, PT_COMPL_SET, BOOL_TRUE);
+	return srp_compl_or_help(context, BOOL_FALSE, PT_COMPL_SET, BOOL_TRUE, BOOL_FALSE);
 }
 
 
 int srp_help_set(kcontext_t *context)
 {
-	return srp_compl_or_help(context, BOOL_TRUE, PT_COMPL_SET, BOOL_TRUE);
+	return srp_compl_or_help(context, BOOL_TRUE, PT_COMPL_SET, BOOL_TRUE, BOOL_FALSE);
 }
 
 
 int srp_compl_del(kcontext_t *context)
 {
-	return srp_compl_or_help(context, BOOL_FALSE, PT_COMPL_DEL, BOOL_TRUE);
+	return srp_compl_or_help(context, BOOL_FALSE, PT_COMPL_DEL, BOOL_TRUE, BOOL_TRUE);
 }
 
 
 int srp_help_del(kcontext_t *context)
 {
-	return srp_compl_or_help(context, BOOL_TRUE, PT_COMPL_DEL, BOOL_TRUE);
+	return srp_compl_or_help(context, BOOL_TRUE, PT_COMPL_DEL, BOOL_TRUE, BOOL_TRUE);
 }
 
 
 int srp_compl_edit(kcontext_t *context)
 {
-	return srp_compl_or_help(context, BOOL_FALSE, PT_COMPL_EDIT, BOOL_TRUE);
+	return srp_compl_or_help(context, BOOL_FALSE, PT_COMPL_EDIT, BOOL_TRUE, BOOL_FALSE);
 }
 
 
 int srp_compl_edit_abs(kcontext_t *context)
 {
-	return srp_compl_or_help(context, BOOL_FALSE, PT_COMPL_EDIT, BOOL_FALSE);
+	return srp_compl_or_help(context, BOOL_FALSE, PT_COMPL_EDIT, BOOL_FALSE, BOOL_FALSE);
 }
 
 
 int srp_help_edit(kcontext_t *context)
 {
-	return srp_compl_or_help(context, BOOL_TRUE, PT_COMPL_EDIT, BOOL_TRUE);
+	return srp_compl_or_help(context, BOOL_TRUE, PT_COMPL_EDIT, BOOL_TRUE, BOOL_FALSE);
 }
 
 
 int srp_help_edit_abs(kcontext_t *context)
 {
-	return srp_compl_or_help(context, BOOL_TRUE, PT_COMPL_EDIT, BOOL_FALSE);
+	return srp_compl_or_help(context, BOOL_TRUE, PT_COMPL_EDIT, BOOL_FALSE, BOOL_FALSE);
 }
 
 
 int srp_compl_insert(kcontext_t *context)
 {
-	return srp_compl_or_help(context, BOOL_FALSE, PT_COMPL_INSERT, BOOL_TRUE);
+	return srp_compl_or_help(context, BOOL_FALSE, PT_COMPL_INSERT, BOOL_TRUE, BOOL_TRUE);
 }
 
 
 int srp_help_insert(kcontext_t *context)
 {
-	return srp_compl_or_help(context, BOOL_TRUE, PT_COMPL_INSERT, BOOL_TRUE);
+	return srp_compl_or_help(context, BOOL_TRUE, PT_COMPL_INSERT, BOOL_TRUE, BOOL_TRUE);
 }
 
 
@@ -371,7 +371,7 @@ static int srp_compl_or_help_insert_to(kcontext_t *context, bool_t help)
 		cur_path, NULL, srp_udata_opts(context));
 	pline = pline_parse(sess, args, srp_udata_opts(context));
 	faux_argv_free(args);
-	pline_print_completions(pline, help, PT_COMPL_INSERT);
+	pline_print_completions(pline, help, PT_COMPL_INSERT, BOOL_TRUE);
 	pline_free(pline);
 
 	return 0;