summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2017-04-20 08:56:31 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2017-04-20 14:08:43 +0200
commit5544b66bbdeaa4bba1051aec1cf8ecc08586f9b9 (patch)
tree8b19739f66bab68b377c8ab93f6a942c39391ce4
parent2f0bb3327b30622ac6ede8b8e93b9a13ecb35408 (diff)
downloadNetworkManager-bg/cli-completion.tar.gz
cli: fix completion of connection typesbg/cli-completion
Return only main settings and the special slave types.
-rw-r--r--clients/cli/common.c9
-rw-r--r--clients/cli/connections.c25
2 files changed, 29 insertions, 5 deletions
diff --git a/clients/cli/common.c b/clients/cli/common.c
index e37d9d8c8b..c9e0bbbd43 100644
--- a/clients/cli/common.c
+++ b/clients/cli/common.c
@@ -1137,8 +1137,13 @@ _rl_compentry_func_wrap_fcn (const char *text, int state)
{
g_return_val_if_fail (_rl_compentry_func_wrap.initialized, NULL);
- if ( !_rl_compentry_func_wrap.values
- || !_rl_compentry_func_wrap.values[_rl_compentry_func_wrap.idx]) {
+ while ( _rl_compentry_func_wrap.values
+ && _rl_compentry_func_wrap.values[_rl_compentry_func_wrap.idx]
+ && !g_str_has_prefix (_rl_compentry_func_wrap.values[_rl_compentry_func_wrap.idx], text))
+ _rl_compentry_func_wrap.idx++;
+
+ if ( !_rl_compentry_func_wrap.values
+ || !_rl_compentry_func_wrap.values[_rl_compentry_func_wrap.idx]) {
g_strfreev (_rl_compentry_func_wrap.values);
_rl_compentry_func_wrap.values = NULL;
_rl_compentry_func_wrap.initialized = FALSE;
diff --git a/clients/cli/connections.c b/clients/cli/connections.c
index bc10949e57..9227f8b5ab 100644
--- a/clients/cli/connections.c
+++ b/clients/cli/connections.c
@@ -4962,10 +4962,29 @@ gen_cmd_save (const char *text, int state)
static rl_compentry_func_t *
gen_connection_types (const char *text)
{
- gs_strfreev char **values = NULL;
+ gs_free char **values = NULL;
+ const NMMetaSettingInfoEditor *editor;
+ GPtrArray *array;
+ int i;
+
+ array = g_ptr_array_new ();
+
+ for (i = 0; i < _NM_META_SETTING_TYPE_NUM; i++) {
+ editor = &nm_meta_setting_infos_editor[i];
+ if (!editor->valid_parts)
+ continue;
+ g_ptr_array_add (array, (gpointer) nm_meta_setting_infos[i].setting_name);
+ if (editor->alias)
+ g_ptr_array_add (array, (gpointer) editor->alias);
+ }
+
+ g_ptr_array_add (array, "bond-slave");
+ g_ptr_array_add (array, "bridge-slave");
+ g_ptr_array_add (array, "team-slave");
+ g_ptr_array_add (array, NULL);
+
+ values = (char **) g_ptr_array_free (array, FALSE);
- values = _meta_abstract_complete ((const NMMetaAbstractInfo *) nm_meta_property_info_connection_type,
- text);
return nmc_rl_compentry_func_wrap ((const char *const*) values);
}