diff options
Diffstat (limited to 'clients/cli/nmcli.c')
| -rw-r--r-- | clients/cli/nmcli.c | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/clients/cli/nmcli.c b/clients/cli/nmcli.c index bbfc310d..d7bc2a46 100644 --- a/clients/cli/nmcli.c +++ b/clients/cli/nmcli.c @@ -24,7 +24,6 @@ #include "nmcli.h" #include <stdio.h> -#include <string.h> #include <stdlib.h> #include <signal.h> #include <termios.h> @@ -245,19 +244,19 @@ usage (void) g_printerr (_("Usage: nmcli [OPTIONS] OBJECT { COMMAND | help }\n" "\n" "OPTIONS\n" - " -o[verview] overview mode (hide default values)\n" - " -t[erse] terse output\n" - " -p[retty] pretty output\n" - " -m[ode] tabular|multiline output mode\n" - " -c[olors] auto|yes|no whether to use colors in output\n" - " -f[ields] <field1,field2,...>|all|common specify fields to output\n" - " -g[et-values] <field1,field2,...>|all|common shortcut for -m tabular -t -f\n" - " -e[scape] yes|no escape columns separators in values\n" - " -a[sk] ask for missing parameters\n" - " -s[how-secrets] allow displaying passwords\n" - " -w[ait] <seconds> set timeout waiting for finishing operations\n" - " -v[ersion] show program version\n" - " -h[elp] print this help\n" + " -a, --ask ask for missing parameters\n" + " -c, --colors auto|yes|no whether to use colors in output\n" + " -e, --escape yes|no escape columns separators in values\n" + " -f, --fields <field,...>|all|common specify fields to output\n" + " -g, --get-values <field,...>|all|common shortcut for -m tabular -t -f\n" + " -h, --help print this help\n" + " -m, --mode tabular|multiline output mode\n" + " -o, --overview overview mode\n" + " -p, --pretty pretty output\n" + " -s, --show-secrets allow displaying passwords\n" + " -t, --terse terse output\n" + " -v, --version show program version\n" + " -w, --wait <seconds> set timeout waiting for finishing operations\n" "\n" "OBJECT\n" " g[eneral] NetworkManager's general status and operations\n" @@ -504,7 +503,7 @@ resolve_color_alias (const char *color) static const struct { const char *name; const char *alias; - } const aliases[] = { + } aliases[] = { { "reset", "0" }, { "bold", "1" }, { "white", "1;37" }, @@ -998,6 +997,14 @@ nmc_value_transforms_register (void) nmc_convert_bytes_to_string); } +void +nm_cli_spawn_pager (NmCli *nmc) +{ + if (nmc->pager_pid > 0) + return; + nmc->pager_pid = nmc_terminal_spawn_pager (&nmc->nmc_config); +} + static void nmc_cleanup (NmCli *nmc) { @@ -1005,15 +1012,15 @@ nmc_cleanup (NmCli *nmc) g_clear_object (&nmc->client); - g_string_free (nmc->return_text, TRUE); + if (nmc->return_text) + g_string_free (g_steal_pointer (&nmc->return_text), TRUE); if (nmc->secret_agent) { - /* Destroy secret agent if we have one. */ - nm_secret_agent_old_unregister (nmc->secret_agent, NULL, NULL); - g_object_unref (nmc->secret_agent); + nm_secret_agent_old_unregister (NM_SECRET_AGENT_OLD (nmc->secret_agent), NULL, NULL); + g_clear_object (&nmc->secret_agent); } - if (nmc->pwds_hash) - g_hash_table_destroy (nmc->pwds_hash); + + nm_clear_pointer (&nmc->pwds_hash, g_hash_table_destroy); nm_clear_g_free (&nmc->required_fields); |