mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-03 13:40:39 +01:00
cli: pass configuration options separately from NmCli structure
The NmCli structure is passed around everywhere and contains all the state of the program. It is very hard to follow which parts are used where. Split out more configuration options to a NmcConfig field. This field is mostly immutable, and modified at particular places that now can be easily found.
This commit is contained in:
parent
9359d5622e
commit
e847d0f121
9 changed files with 66 additions and 63 deletions
|
|
@ -125,7 +125,7 @@ secrets_requested (NMSecretAgentSimple *agent,
|
|||
NmCli *nmc = (NmCli *) user_data;
|
||||
gboolean success = FALSE;
|
||||
|
||||
if (nmc->print_output == NMC_PRINT_PRETTY)
|
||||
if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY)
|
||||
nmc_terminal_erase_line ();
|
||||
|
||||
success = get_secrets_from_user (request_id, title, msg, secrets);
|
||||
|
|
|
|||
|
|
@ -843,7 +843,7 @@ nmc_secrets_requested (NMSecretAgentSimple *agent,
|
|||
gboolean success = FALSE;
|
||||
const GPtrArray *connections;
|
||||
|
||||
if (nmc->print_output == NMC_PRINT_PRETTY)
|
||||
if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY)
|
||||
nmc_terminal_erase_line ();
|
||||
|
||||
/* Find the connection for the request */
|
||||
|
|
@ -857,7 +857,7 @@ nmc_secrets_requested (NMSecretAgentSimple *agent,
|
|||
g_free (path);
|
||||
}
|
||||
|
||||
success = get_secrets_from_user (request_id, title, msg, connection, nmc->in_editor || nmc->ask,
|
||||
success = get_secrets_from_user (request_id, title, msg, connection, nmc->nmc_config.in_editor || nmc->ask,
|
||||
nmc->show_secrets, nmc->pwds_hash, secrets);
|
||||
if (success)
|
||||
nm_secret_agent_simple_response (agent, request_id, secrets);
|
||||
|
|
@ -976,7 +976,7 @@ read_again:
|
|||
if (nmc_seen_sigint ()) {
|
||||
/* Ctrl-C */
|
||||
nmc_clear_sigint ();
|
||||
if ( nm_cli.in_editor
|
||||
if ( nm_cli.nmc_config.in_editor
|
||||
|| (rl_string && *rl_string)) {
|
||||
/* In editor, or the line is not empty */
|
||||
/* Call readline again to get new prompt (repeat) */
|
||||
|
|
|
|||
|
|
@ -803,7 +803,7 @@ nmc_connection_profile_details (NMConnection *connection, NmCli *nmc, gboolean s
|
|||
int section_idx = g_array_index (print_settings_array, int, i);
|
||||
const char *prop_name = (const char *) g_ptr_array_index (prop_array, i);
|
||||
|
||||
if (nmc->print_output != NMC_PRINT_TERSE && !nmc->multiline_output && was_output)
|
||||
if (nmc->nmc_config.print_output != NMC_PRINT_TERSE && !nmc->nmc_config.multiline_output && was_output)
|
||||
g_print ("\n"); /* Empty line */
|
||||
|
||||
was_output = FALSE;
|
||||
|
|
@ -1229,7 +1229,7 @@ nmc_active_connection_details (NMActiveConnection *acon, NmCli *nmc)
|
|||
int group_idx = g_array_index (print_groups, int, i);
|
||||
char *group_fld = (char *) g_ptr_array_index (group_fields, i);
|
||||
|
||||
if (nmc->print_output != NMC_PRINT_TERSE && !nmc->multiline_output && was_output)
|
||||
if (nmc->nmc_config.print_output != NMC_PRINT_TERSE && !nmc->nmc_config.multiline_output && was_output)
|
||||
g_print ("\n"); /* Empty line */
|
||||
|
||||
was_output = FALSE;
|
||||
|
|
@ -1840,7 +1840,7 @@ do_connections_show (NmCli *nmc, int argc, char **argv)
|
|||
|
||||
/* multiline mode is default for 'connection show <ID>' */
|
||||
if (!nmc->mode_specified)
|
||||
nmc->multiline_output = TRUE;
|
||||
nmc->nmc_config_mutable.multiline_output = TRUE;
|
||||
|
||||
/* Split required fields into the settings and active ones. */
|
||||
if (!split_required_fields_for_con_show (nmc->required_fields, &profile_flds, &active_flds, &err))
|
||||
|
|
@ -2188,7 +2188,7 @@ check_activated (ActivateConnectionInfo *info)
|
|||
}
|
||||
|
||||
if (ac_state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
|
||||
if (nmc->print_output == NMC_PRINT_PRETTY)
|
||||
if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY)
|
||||
nmc_terminal_erase_line ();
|
||||
g_print (_("Connection successfully activated (D-Bus active path: %s)\n"),
|
||||
nm_object_get_path (NM_OBJECT (active)));
|
||||
|
|
@ -2228,7 +2228,7 @@ check_activated (ActivateConnectionInfo *info)
|
|||
|| NM_IS_DEVICE_BRIDGE (device))
|
||||
&& dev_state >= NM_DEVICE_STATE_IP_CONFIG
|
||||
&& dev_state <= NM_DEVICE_STATE_ACTIVATED) {
|
||||
if (nmc->print_output == NMC_PRINT_PRETTY)
|
||||
if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY)
|
||||
nmc_terminal_erase_line ();
|
||||
g_print (_("Connection successfully activated (master waiting for slaves) (D-Bus active path: %s)\n"),
|
||||
nm_object_get_path (NM_OBJECT (active)));
|
||||
|
|
@ -2358,7 +2358,7 @@ activate_connection_cb (GObject *client, GAsyncResult *result, gpointer user_dat
|
|||
if (nmc->nowait_flag || state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
|
||||
/* User doesn't want to wait or already activated */
|
||||
if (state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
|
||||
if (nmc->print_output == NMC_PRINT_PRETTY)
|
||||
if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY)
|
||||
nmc_terminal_erase_line ();
|
||||
g_print (_("Connection successfully activated (D-Bus active path: %s)\n"),
|
||||
nm_object_get_path (NM_OBJECT (active)));
|
||||
|
|
@ -2378,7 +2378,7 @@ activate_connection_cb (GObject *client, GAsyncResult *result, gpointer user_dat
|
|||
}
|
||||
|
||||
/* Start progress indication showing VPN states */
|
||||
if (nmc->print_output == NMC_PRINT_PRETTY) {
|
||||
if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY) {
|
||||
if (progress_id)
|
||||
g_source_remove (progress_id);
|
||||
progress_id = g_timeout_add (120, progress_active_connection_cb, active);
|
||||
|
|
@ -2666,7 +2666,7 @@ do_connection_up (NmCli *nmc, int argc, char **argv)
|
|||
}
|
||||
|
||||
/* Start progress indication */
|
||||
if (nmc->print_output == NMC_PRINT_PRETTY)
|
||||
if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY)
|
||||
progress_id = g_timeout_add (120, progress_cb, _("preparing"));
|
||||
|
||||
return nmc->return_value;
|
||||
|
|
@ -2701,7 +2701,7 @@ down_active_connection_state_cb (NMActiveConnection *active,
|
|||
if (nm_active_connection_get_state (active) < NM_ACTIVE_CONNECTION_STATE_DEACTIVATED)
|
||||
return;
|
||||
|
||||
if (info->nmc->print_output == NMC_PRINT_PRETTY)
|
||||
if (info->nmc->nmc_config.print_output == NMC_PRINT_PRETTY)
|
||||
nmc_terminal_erase_line ();
|
||||
g_print (_("Connection '%s' successfully deactivated (D-Bus active path: %s)\n"),
|
||||
nm_active_connection_get_id (active), nm_object_get_path (NM_OBJECT (active)));
|
||||
|
|
@ -6015,9 +6015,9 @@ save_history_cmds (const char *uuid)
|
|||
static void
|
||||
editor_show_connection (NMConnection *connection, NmCli *nmc)
|
||||
{
|
||||
nmc->print_output = NMC_PRINT_PRETTY;
|
||||
nmc->multiline_output = TRUE;
|
||||
nmc->escape_values = 0;
|
||||
nmc->nmc_config_mutable.print_output = NMC_PRINT_PRETTY;
|
||||
nmc->nmc_config_mutable.multiline_output = TRUE;
|
||||
nmc->nmc_config_mutable.escape_values = 0;
|
||||
|
||||
/* Remove any previous data */
|
||||
nmc_empty_output_fields (nmc);
|
||||
|
|
@ -6031,9 +6031,9 @@ editor_show_setting (NMSetting *setting, NmCli *nmc)
|
|||
g_print (_("['%s' setting values]\n"),
|
||||
nm_setting_get_name (setting));
|
||||
|
||||
nmc->print_output = NMC_PRINT_NORMAL;
|
||||
nmc->multiline_output = TRUE;
|
||||
nmc->escape_values = 0;
|
||||
nmc->nmc_config_mutable.print_output = NMC_PRINT_NORMAL;
|
||||
nmc->nmc_config_mutable.multiline_output = TRUE;
|
||||
nmc->nmc_config_mutable.escape_values = 0;
|
||||
|
||||
/* Remove any previous data */
|
||||
nmc_empty_output_fields (nmc);
|
||||
|
|
@ -7627,7 +7627,7 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
|
|||
|
||||
nmc->nowait_flag = FALSE;
|
||||
nmc->should_wait++;
|
||||
nmc->print_output = NMC_PRINT_PRETTY;
|
||||
nmc->nmc_config_mutable.print_output = NMC_PRINT_PRETTY;
|
||||
if (!nmc_activate_connection (nmc, NM_CONNECTION (rem_con), ifname, ap_nsp, ap_nsp, NULL,
|
||||
activate_connection_editor_cb, &tmp_err)) {
|
||||
g_print (_("Error: Cannot activate connection: %s.\n"), tmp_err->message);
|
||||
|
|
@ -8052,7 +8052,7 @@ do_connection_edit (NmCli *nmc, int argc, char **argv)
|
|||
}
|
||||
|
||||
/* nmcli runs the editor */
|
||||
nmc->in_editor = TRUE;
|
||||
nmc->nmc_config_mutable.in_editor = TRUE;
|
||||
|
||||
g_print ("\n");
|
||||
g_print (_("===| nmcli interactive connection editor |==="));
|
||||
|
|
@ -8105,7 +8105,7 @@ modify_connection_cb (GObject *connection,
|
|||
g_error_free (error);
|
||||
nmc->return_value = NMC_RESULT_ERROR_UNKNOWN;
|
||||
} else {
|
||||
if (nmc->print_output == NMC_PRINT_PRETTY)
|
||||
if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY)
|
||||
g_print (_("Connection '%s' (%s) successfully modified.\n"),
|
||||
nm_connection_get_id (NM_CONNECTION (connection)),
|
||||
nm_connection_get_uuid (NM_CONNECTION (connection)));
|
||||
|
|
|
|||
|
|
@ -1117,7 +1117,7 @@ show_device_info (NMDevice *device, NmCli *nmc)
|
|||
int section_idx = g_array_index (sections_array, int, k);
|
||||
char *section_fld = (char *) g_ptr_array_index (fields_in_section, k);
|
||||
|
||||
if (nmc->print_output != NMC_PRINT_TERSE && !nmc->multiline_output && was_output)
|
||||
if (nmc->nmc_config.print_output != NMC_PRINT_TERSE && !nmc->nmc_config.multiline_output && was_output)
|
||||
g_print ("\n"); /* Print empty line between groups in tabular mode */
|
||||
|
||||
was_output = FALSE;
|
||||
|
|
@ -1544,7 +1544,7 @@ do_device_show (NmCli *nmc, int argc, char **argv)
|
|||
gs_free_error GError *error = NULL;
|
||||
|
||||
if (!nmc->mode_specified)
|
||||
nmc->multiline_output = TRUE; /* multiline mode is default for 'device show' */
|
||||
nmc->nmc_config_mutable.multiline_output = TRUE; /* multiline mode is default for 'device show' */
|
||||
|
||||
if (argc) {
|
||||
NMDevice *device;
|
||||
|
|
@ -1708,7 +1708,7 @@ add_and_activate_cb (GObject *client,
|
|||
if (nmc->nowait_flag || state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
|
||||
/* User doesn't want to wait or already activated */
|
||||
if (state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
|
||||
if (nmc->print_output == NMC_PRINT_PRETTY)
|
||||
if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY)
|
||||
nmc_terminal_erase_line ();
|
||||
if (info->hotspot)
|
||||
g_print (_("Connection with UUID '%s' created and activated on device '%s'\n"),
|
||||
|
|
@ -1726,7 +1726,7 @@ add_and_activate_cb (GObject *client,
|
|||
|
||||
g_timeout_add_seconds (nmc->timeout, timeout_cb, nmc); /* Exit if timeout expires */
|
||||
|
||||
if (nmc->print_output == NMC_PRINT_PRETTY)
|
||||
if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY)
|
||||
progress_id = g_timeout_add (120, progress_cb, device);
|
||||
}
|
||||
}
|
||||
|
|
@ -1800,7 +1800,7 @@ connect_device_cb (GObject *client, GAsyncResult *result, gpointer user_data)
|
|||
|
||||
if (nmc->nowait_flag || state == NM_DEVICE_STATE_ACTIVATED) {
|
||||
/* Don't want to wait or device already activated */
|
||||
if (state == NM_DEVICE_STATE_ACTIVATED && nmc->print_output == NMC_PRINT_PRETTY) {
|
||||
if (state == NM_DEVICE_STATE_ACTIVATED && nmc->nmc_config.print_output == NMC_PRINT_PRETTY) {
|
||||
nmc_terminal_erase_line ();
|
||||
g_print (_("Device '%s' has been connected.\n"), nm_device_get_iface (device));
|
||||
}
|
||||
|
|
@ -1879,7 +1879,7 @@ do_device_connect (NmCli *nmc, int argc, char **argv)
|
|||
info);
|
||||
|
||||
/* Start progress indication */
|
||||
if (nmc->print_output == NMC_PRINT_PRETTY)
|
||||
if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY)
|
||||
progress_id = g_timeout_add (120, progress_cb, device);
|
||||
|
||||
return nmc->return_value;
|
||||
|
|
@ -1984,7 +1984,7 @@ reapply_device_cb (GObject *object, GAsyncResult *result, gpointer user_data)
|
|||
nmc->return_value = NMC_RESULT_ERROR_DEV_DISCONNECT;
|
||||
device_cb_info_finish (info, device);
|
||||
} else {
|
||||
if (nmc->print_output == NMC_PRINT_PRETTY)
|
||||
if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY)
|
||||
nmc_terminal_erase_line ();
|
||||
g_print (_("Connection successfully reapplied to device '%s'.\n"),
|
||||
nm_device_get_iface (device));
|
||||
|
|
@ -2052,7 +2052,7 @@ modify_reapply_cb (GObject *object, GAsyncResult *result, gpointer user_data)
|
|||
g_error_free (error);
|
||||
nmc->return_value = NMC_RESULT_ERROR_DEV_DISCONNECT;
|
||||
} else {
|
||||
if (nmc->print_output == NMC_PRINT_PRETTY)
|
||||
if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY)
|
||||
nmc_terminal_erase_line ();
|
||||
g_print (_("Connection successfully reapplied to device '%s'.\n"),
|
||||
nm_device_get_iface (device));
|
||||
|
|
@ -2155,7 +2155,7 @@ disconnect_device_cb (GObject *object, GAsyncResult *result, gpointer user_data)
|
|||
if (nmc->nowait_flag || state <= NM_DEVICE_STATE_DISCONNECTED) {
|
||||
/* Don't want to wait or device already disconnected */
|
||||
if (state <= NM_DEVICE_STATE_DISCONNECTED) {
|
||||
if (nmc->print_output == NMC_PRINT_PRETTY)
|
||||
if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY)
|
||||
nmc_terminal_erase_line ();
|
||||
g_print (_("Device '%s' successfully disconnected.\n"),
|
||||
nm_device_get_iface (device));
|
||||
|
|
@ -3817,7 +3817,7 @@ static NMCResultCode
|
|||
do_device_lldp (NmCli *nmc, int argc, char **argv)
|
||||
{
|
||||
if (!nmc->mode_specified)
|
||||
nmc->multiline_output = TRUE; /* multiline mode is default for 'device lldp' */
|
||||
nmc->nmc_config_mutable.multiline_output = TRUE; /* multiline mode is default for 'device lldp' */
|
||||
|
||||
nmc_do_cmd (nmc, device_lldp_cmds, *argv, argc, argv);
|
||||
|
||||
|
|
|
|||
|
|
@ -786,8 +786,8 @@ nmc_switch_show (NmCli *nmc, const char *switch_name, const char *header)
|
|||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
return FALSE;
|
||||
}
|
||||
if (nmc->print_output == NMC_PRINT_NORMAL)
|
||||
nmc->print_output = NMC_PRINT_TERSE;
|
||||
if (nmc->nmc_config.print_output == NMC_PRINT_NORMAL)
|
||||
nmc->nmc_config_mutable.print_output = NMC_PRINT_TERSE;
|
||||
|
||||
if (!nmc->required_fields)
|
||||
nmc->required_fields = g_strdup (switch_name);
|
||||
|
|
|
|||
|
|
@ -235,31 +235,31 @@ process_command_line (NmCli *nmc, int argc, char **argv)
|
|||
}
|
||||
|
||||
if (matches (opt, "-terse")) {
|
||||
if (nmc->print_output == NMC_PRINT_TERSE) {
|
||||
if (nmc->nmc_config.print_output == NMC_PRINT_TERSE) {
|
||||
g_string_printf (nmc->return_text, _("Error: Option '--terse' is specified the second time."));
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
return FALSE;
|
||||
}
|
||||
else if (nmc->print_output == NMC_PRINT_PRETTY) {
|
||||
else if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY) {
|
||||
g_string_printf (nmc->return_text, _("Error: Option '--terse' is mutually exclusive with '--pretty'."));
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
nmc->print_output = NMC_PRINT_TERSE;
|
||||
nmc->nmc_config_mutable.print_output = NMC_PRINT_TERSE;
|
||||
} else if (matches (opt, "-pretty")) {
|
||||
if (nmc->print_output == NMC_PRINT_PRETTY) {
|
||||
if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY) {
|
||||
g_string_printf (nmc->return_text, _("Error: Option '--pretty' is specified the second time."));
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
return FALSE;
|
||||
}
|
||||
else if (nmc->print_output == NMC_PRINT_TERSE) {
|
||||
else if (nmc->nmc_config.print_output == NMC_PRINT_TERSE) {
|
||||
g_string_printf (nmc->return_text, _("Error: Option '--pretty' is mutually exclusive with '--terse'."));
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
nmc->print_output = NMC_PRINT_PRETTY;
|
||||
nmc->nmc_config_mutable.print_output = NMC_PRINT_PRETTY;
|
||||
} else if (matches (opt, "-mode")) {
|
||||
nmc->mode_specified = TRUE;
|
||||
argc--;
|
||||
|
|
@ -272,9 +272,9 @@ process_command_line (NmCli *nmc, int argc, char **argv)
|
|||
if (argc == 1 && nmc->complete)
|
||||
nmc_complete_strings (argv[0], "tabular", "multiline", NULL);
|
||||
if (matches (argv[0], "tabular"))
|
||||
nmc->multiline_output = FALSE;
|
||||
nmc->nmc_config_mutable.multiline_output = FALSE;
|
||||
else if (matches (argv[0], "multiline"))
|
||||
nmc->multiline_output = TRUE;
|
||||
nmc->nmc_config_mutable.multiline_output = TRUE;
|
||||
else {
|
||||
g_string_printf (nmc->return_text, _("Error: '%s' is not valid argument for '%s' option."), argv[0], opt);
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
|
|
@ -291,11 +291,11 @@ process_command_line (NmCli *nmc, int argc, char **argv)
|
|||
if (argc == 1 && nmc->complete)
|
||||
nmc_complete_strings (argv[0], "yes", "no", "auto", NULL);
|
||||
if (matches (argv[0], "auto"))
|
||||
nmc->nmc_config.use_colors = NMC_USE_COLOR_AUTO;
|
||||
nmc->nmc_config_mutable.use_colors = NMC_USE_COLOR_AUTO;
|
||||
else if (matches (argv[0], "yes"))
|
||||
nmc->nmc_config.use_colors = NMC_USE_COLOR_YES;
|
||||
nmc->nmc_config_mutable.use_colors = NMC_USE_COLOR_YES;
|
||||
else if (matches (argv[0], "no"))
|
||||
nmc->nmc_config.use_colors = NMC_USE_COLOR_NO;
|
||||
nmc->nmc_config_mutable.use_colors = NMC_USE_COLOR_NO;
|
||||
else {
|
||||
g_string_printf (nmc->return_text, _("Error: '%s' is not valid argument for '%s' option."), argv[0], opt);
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
|
|
@ -312,9 +312,9 @@ process_command_line (NmCli *nmc, int argc, char **argv)
|
|||
if (argc == 1 && nmc->complete)
|
||||
nmc_complete_strings (argv[0], "yes", "no", NULL);
|
||||
if (matches (argv[0], "yes"))
|
||||
nmc->escape_values = TRUE;
|
||||
nmc->nmc_config_mutable.escape_values = TRUE;
|
||||
else if (matches (argv[0], "no"))
|
||||
nmc->escape_values = FALSE;
|
||||
nmc->nmc_config_mutable.escape_values = FALSE;
|
||||
else {
|
||||
g_string_printf (nmc->return_text, _("Error: '%s' is not valid argument for '%s' option."), argv[0], opt);
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
|
|
@ -342,7 +342,7 @@ process_command_line (NmCli *nmc, int argc, char **argv)
|
|||
if (argc == 1 && nmc->complete)
|
||||
complete_fields (argv[0]);
|
||||
nmc->required_fields = g_strdup (argv[0]);
|
||||
nmc->print_output = NMC_PRINT_TERSE;
|
||||
nmc->nmc_config_mutable.print_output = NMC_PRINT_TERSE;
|
||||
/* We want fixed tabular mode here, but just set the mode specified and rely on the initialization
|
||||
* in nmc_init: in this way we allow use of "-m multiline" to swap the output mode also if placed
|
||||
* before the "-g <field>" option (-g may be still more practical and easy to remember than -t -f).
|
||||
|
|
@ -535,18 +535,18 @@ nmc_init (NmCli *nmc)
|
|||
|
||||
nmc->should_wait = 0;
|
||||
nmc->nowait_flag = TRUE;
|
||||
nmc->print_output = NMC_PRINT_NORMAL;
|
||||
nmc->multiline_output = FALSE;
|
||||
nmc->nmc_config_mutable.print_output = NMC_PRINT_NORMAL;
|
||||
nmc->nmc_config_mutable.multiline_output = FALSE;
|
||||
nmc->mode_specified = FALSE;
|
||||
nmc->escape_values = TRUE;
|
||||
nmc->nmc_config_mutable.escape_values = TRUE;
|
||||
nmc->required_fields = NULL;
|
||||
nmc->output_data = g_ptr_array_new_full (20, g_free);
|
||||
memset (&nmc->print_fields, '\0', sizeof (NmcPrintFields));
|
||||
nmc->ask = FALSE;
|
||||
nmc->complete = FALSE;
|
||||
nmc->show_secrets = FALSE;
|
||||
nmc->nmc_config.use_colors = NMC_USE_COLOR_AUTO;
|
||||
nmc->in_editor = FALSE;
|
||||
nmc->nmc_config_mutable.use_colors = NMC_USE_COLOR_AUTO;
|
||||
nmc->nmc_config_mutable.in_editor = FALSE;
|
||||
nmc->editor_status_line = FALSE;
|
||||
nmc->editor_save_confirmation = TRUE;
|
||||
nmc->editor_show_secrets = FALSE;
|
||||
|
|
|
|||
|
|
@ -139,7 +139,11 @@ typedef enum {
|
|||
} NmcColorOption;
|
||||
|
||||
typedef struct _NmcConfig {
|
||||
NMCPrintOutput print_output; /* Output mode */
|
||||
NmcColorOption use_colors; /* Whether to use colors for output: option '--color' */
|
||||
gboolean multiline_output; /* Multiline output instead of default tabular */
|
||||
gboolean escape_values; /* Whether to escape ':' and '\' in terse tabular mode */
|
||||
gboolean in_editor; /* Whether running the editor - nmcli con edit' */
|
||||
} NmcConfig;
|
||||
|
||||
/* NmCli - main structure */
|
||||
|
|
@ -157,18 +161,17 @@ typedef struct _NmCli {
|
|||
|
||||
int should_wait; /* Semaphore indicating whether nmcli should not end or not yet */
|
||||
gboolean nowait_flag; /* '--nowait' option; used for passing to callbacks */
|
||||
NMCPrintOutput print_output; /* Output mode */
|
||||
gboolean multiline_output; /* Multiline output instead of default tabular */
|
||||
gboolean mode_specified; /* Whether tabular/multiline mode was specified via '--mode' option */
|
||||
NmcConfig nmc_config;
|
||||
gboolean escape_values; /* Whether to escape ':' and '\' in terse tabular mode */
|
||||
union {
|
||||
const NmcConfig nmc_config;
|
||||
NmcConfig nmc_config_mutable;
|
||||
};
|
||||
char *required_fields; /* Required fields in output: '--fields' option */
|
||||
GPtrArray *output_data; /* GPtrArray of arrays of NmcOutputField structs - accumulates data for output */
|
||||
NmcPrintFields print_fields; /* Structure with field indices to print */
|
||||
gboolean ask; /* Ask for missing parameters: option '--ask' */
|
||||
gboolean complete; /* Autocomplete the command line */
|
||||
gboolean show_secrets; /* Whether to display secrets (both input and output): option '--show-secrets' */
|
||||
gboolean in_editor; /* Whether running the editor - nmcli con edit' */
|
||||
gboolean editor_status_line; /* Whether to display status line in connection editor */
|
||||
gboolean editor_save_confirmation; /* Whether to ask for confirmation on saving connections with 'autoconnect=yes' */
|
||||
gboolean editor_show_secrets; /* Whether to display secrets in the editor' */
|
||||
|
|
|
|||
|
|
@ -891,7 +891,7 @@ setting_details (NMSetting *setting, NmCli *nmc, const char *one_prop, gboolean
|
|||
|
||||
g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (setting, setting_info->general->get_setting_gtype ()), FALSE);
|
||||
|
||||
if (nmc->print_output == NMC_PRINT_TERSE)
|
||||
if (nmc->nmc_config.print_output == NMC_PRINT_TERSE)
|
||||
type = NM_META_ACCESSOR_GET_TYPE_PARSABLE;
|
||||
|
||||
tmpl_len = sizeof (NmcOutputField) * (setting_info->properties_num + 1);
|
||||
|
|
|
|||
|
|
@ -873,10 +873,10 @@ print_required_fields (NmCli *nmc, const NmcOutputField field_values[])
|
|||
const char *not_set_str = "--";
|
||||
int i;
|
||||
const NmcPrintFields fields = nmc->print_fields;
|
||||
gboolean multiline = nmc->multiline_output;
|
||||
gboolean terse = (nmc->print_output == NMC_PRINT_TERSE);
|
||||
gboolean pretty = (nmc->print_output == NMC_PRINT_PRETTY);
|
||||
gboolean escape = nmc->escape_values;
|
||||
gboolean multiline = nmc->nmc_config.multiline_output;
|
||||
gboolean terse = (nmc->nmc_config.print_output == NMC_PRINT_TERSE);
|
||||
gboolean pretty = (nmc->nmc_config.print_output == NMC_PRINT_PRETTY);
|
||||
gboolean escape = nmc->nmc_config.escape_values;
|
||||
gboolean main_header_add = field_values[0].flags & NMC_OF_FLAG_MAIN_HEADER_ADD;
|
||||
gboolean main_header_only = field_values[0].flags & NMC_OF_FLAG_MAIN_HEADER_ONLY;
|
||||
gboolean field_names = field_values[0].flags & NMC_OF_FLAG_FIELD_NAMES;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue