summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2016-07-07 15:08:00 +0200
committerLubomir Rintel <lkundrak@v3.sk>2016-08-01 13:52:36 +0200
commit075e705bc712988e8343569a9a9f8e8d0e55fe0f (patch)
treee92311f7ede9c5b03a6dfd24ba8013b22f4a85b5
parent9d076a7a1ad30a93d28b154ec1c38694bd2b2707 (diff)
downloadNetworkManager-075e705bc712988e8343569a9a9f8e8d0e55fe0f.tar.gz
cli/connections: add completion to monitor subcommand
-rw-r--r--clients/cli/connections.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c
index 4d99acaf80..9be47aa328 100644
--- a/clients/cli/connections.c
+++ b/clients/cli/connections.c
@@ -8278,14 +8278,13 @@ do_connection_monitor (NmCli *nmc, int argc, char **argv)
{
GError *error = NULL;
- /* Not (yet?) supported */
- if (nmc->complete)
- return nmc->return_value;
-
if (argc == 0) {
/* No connections specified. Monitor all. */
int i;
+ /* nmc_do_cmd() should not call this with argc=0. */
+ g_assert (!nmc->complete);
+
nmc->connections = nm_client_get_connections (nmc->client);
for (i = 0; i < nmc->connections->len; i++)
connection_watch (nmc, g_ptr_array_index (nmc->connections, i));
@@ -8296,26 +8295,29 @@ do_connection_monitor (NmCli *nmc, int argc, char **argv)
} else {
/* Look up the specified connections and watch them. */
NMConnection *connection;
- char **arg_ptr = argv;
- int arg_num = argc;
int pos = 0;
do {
- connection = get_connection (nmc, &arg_num, &arg_ptr, &pos, &error);
- if (connection) {
- connection_watch (nmc, connection);
- } else {
- g_printerr (_("Error: %s.\n"), error->message);
+ connection = get_connection (nmc, &argc, &argv, &pos, &error);
+ if (!connection) {
+ if (!nmc->complete)
+ g_printerr (_("Error: %s.\n"), error->message);
g_string_printf (nmc->return_text, _("Error: not all connections found."));
return error->code;
}
-
/* Take next argument (if there's no other connection of the same name) */
if (!pos)
- next_arg (&arg_num, &arg_ptr);
- } while (arg_num > 0);
+ next_arg (&argc, &argv);
+
+ if (nmc->complete)
+ continue;
+
+ connection_watch (nmc, connection);
+ } while (argc > 0);
}
+ if (nmc->complete)
+ return nmc->return_value;
g_signal_connect (nmc->client, NM_CLIENT_CONNECTION_REMOVED, G_CALLBACK (connection_removed), nmc);
return NMC_RESULT_SUCCESS;