diff options
| author | Michael Biebl <biebl@debian.org> | 2016-10-01 00:33:49 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2016-10-01 00:33:49 +0200 |
| commit | 270c4830551c9810ad4e83f9a1db2b1cb946208c (patch) | |
| tree | 5df09188f7e43b70896efb7b6e942e0b130d75d3 /clients/cli/common.c | |
| parent | 7514efc2f38c9ace4557d4e69d68e7d380389030 (diff) | |
New upstream version 1.4.2 upstream/1.4.2
Diffstat (limited to 'clients/cli/common.c')
| -rw-r--r-- | clients/cli/common.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/clients/cli/common.c b/clients/cli/common.c index f1ec46a1..f8dc5239 100644 --- a/clients/cli/common.c +++ b/clients/cli/common.c @@ -1058,13 +1058,15 @@ get_secrets_from_user (const char *request_id, nmc_rl_pre_input_deftext = g_strdup (secret->value); } } - g_print ("%s\n", msg); + if (msg) + g_print ("%s\n", msg); pwd = nmc_readline_echo (secret->password ? echo_on : TRUE, "%s (%s): ", secret->name, secret->prop_name); if (!pwd) pwd = g_strdup (""); } else { - g_print ("%s\n", msg); + if (msg) + g_print ("%s\n", msg); g_printerr (_("Warning: password for '%s' not given in 'passwd-file' " "and nmcli cannot ask without '--ask' option.\n"), secret->prop_name); @@ -1354,6 +1356,33 @@ nmc_rl_gen_func_basic (const char *text, int state, const char **words) return NULL; } +char * +nmc_rl_gen_func_ifnames (const char *text, int state) +{ + int i; + const GPtrArray *devices; + const char **ifnames; + char *ret; + + nm_cli.get_client (&nm_cli); + devices = nm_client_get_devices (nm_cli.client); + if (devices->len == 0) + return NULL; + + ifnames = g_new (const char *, devices->len + 1); + for (i = 0; i < devices->len; i++) { + NMDevice *dev = g_ptr_array_index (devices, i); + const char *ifname = nm_device_get_iface (dev); + ifnames[i] = ifname; + } + ifnames[i] = NULL; + + ret = nmc_rl_gen_func_basic (text, state, ifnames); + + g_free (ifnames); + return ret; +} + /* for pre-filling a string to readline prompt */ char *nmc_rl_pre_input_deftext; |