From 4302e05b1a0b0357040459be15ea90cf5cc8f9a7 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Tue, 12 Jul 2016 10:15:01 +0200 Subject: [PATCH] cli/device: make it possible to limit completion to wifis --- clients/cli/devices.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/clients/cli/devices.c b/clients/cli/devices.c index 7990cc7dbf..bceae7380a 100644 --- a/clients/cli/devices.c +++ b/clients/cli/devices.c @@ -538,13 +538,16 @@ nmc_get_devices_sorted (NMClient *client) } static void -complete_device (NMDevice **devices, const char *prefix) +complete_device (NMDevice **devices, const char *prefix, gboolean wifi_only) { int i; for (i = 0; devices[i]; i++) { const char *iface = nm_device_get_iface (devices[i]); + if (wifi_only && !NM_IS_DEVICE_WIFI (devices[i])) + continue; + if (g_str_has_prefix (iface, prefix)) g_print ("%s\n", iface); } @@ -578,7 +581,7 @@ get_device_list (NmCli *nmc, int argc, char **argv) devices = nmc_get_devices_sorted (nmc->client); while (arg_num > 0) { if (arg_num == 1 && nmc->complete) - complete_device (devices, *arg_ptr); + complete_device (devices, *arg_ptr, FALSE); device = NULL; for (i = 0; devices[i]; i++) { @@ -640,7 +643,7 @@ get_device (NmCli *nmc, int *argc, char ***argv, GError **error) } if (nmc->complete && !*argc) - complete_device (devices, ifname); + complete_device (devices, ifname, FALSE); if (devices[i] == NULL) { g_set_error (error, NMCLI_ERROR, NMC_RESULT_ERROR_NOT_FOUND,