Commit 9dacfd0a authored by Jiří Klimeš's avatar Jiří Klimeš

cli: always print success message (not only in --pretty mode) (rh #1006444)

The commands performing actions without an output only printed a successfull
message for --pretty mode. Some users don't like this silent operation.
This commit makes nmcli print operation success unconditionally. I think that
doesn't hurt; scripts/users can ignore the message if not interested.

https://bugzilla.redhat.com/show_bug.cgi?id=1006444
parent 05980f90
......@@ -1297,11 +1297,10 @@ active_connection_state_cb (NMActiveConnection *active, GParamSpec *pspec, gpoin
state = nm_active_connection_get_state (active);
if (state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
if (nmc->print_output == NMC_PRINT_PRETTY) {
if (nmc->print_output == NMC_PRINT_PRETTY)
nmc_terminal_erase_line ();
printf (_("Connection successfully activated (D-Bus active path: %s)\n"),
nm_object_get_path (NM_OBJECT (active)));
}
printf (_("Connection successfully activated (D-Bus active path: %s)\n"),
nm_object_get_path (NM_OBJECT (active)));
quit ();
} else if ( state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED
|| state == NM_ACTIVE_CONNECTION_STATE_UNKNOWN) {
......@@ -1328,11 +1327,10 @@ vpn_connection_state_cb (NMVPNConnection *vpn,
break;
case NM_VPN_CONNECTION_STATE_ACTIVATED:
if (nmc->print_output == NMC_PRINT_PRETTY) {
if (nmc->print_output == NMC_PRINT_PRETTY)
nmc_terminal_erase_line ();
printf (_("VPN connection successfully activated (D-Bus active path: %s)\n"),
nm_object_get_path (NM_OBJECT (vpn)));
}
printf (_("VPN connection successfully activated (D-Bus active path: %s)\n"),
nm_object_get_path (NM_OBJECT (vpn)));
quit ();
break;
......@@ -1456,8 +1454,9 @@ activate_connection_cb (NMClient *client, NMActiveConnection *active, GError *er
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 && nmc->print_output == NMC_PRINT_PRETTY) {
nmc_terminal_erase_line ();
if (state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
if (nmc->print_output == NMC_PRINT_PRETTY)
nmc_terminal_erase_line ();
printf (_("Connection successfully activated (D-Bus active path: %s)\n"),
nm_object_get_path (NM_OBJECT (active)));
}
......@@ -4139,10 +4138,9 @@ add_connection_cb (NMRemoteSettings *settings,
info->con_name, error->code, error->message);
nmc->return_value = NMC_RESULT_ERROR_CON_ACTIVATION;
} else {
if (nmc->print_output == NMC_PRINT_PRETTY)
printf (_("Connection '%s' (%s) successfully added.\n"),
nm_connection_get_id (NM_CONNECTION (connection)),
nm_connection_get_uuid (NM_CONNECTION (connection)));
printf (_("Connection '%s' (%s) successfully added.\n"),
nm_connection_get_id (NM_CONNECTION (connection)),
nm_connection_get_uuid (NM_CONNECTION (connection)));
}
g_free (info->con_name);
......
......@@ -1197,8 +1197,9 @@ disconnect_device_cb (NMDevice *device, GError *error, 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 && nmc->print_output == NMC_PRINT_PRETTY) {
nmc_terminal_erase_line ();
if (state == NM_DEVICE_STATE_DISCONNECTED) {
if (nmc->print_output == NMC_PRINT_PRETTY)
nmc_terminal_erase_line ();
printf (_("Device '%s' has been disconnected.\n"), nm_device_get_iface (device));
}
quit ();
......@@ -1539,13 +1540,12 @@ monitor_device_state_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data
state = nm_device_get_state_reason (device, &reason);
if (state == NM_DEVICE_STATE_ACTIVATED) {
if (nmc->print_output == NMC_PRINT_PRETTY) {
NMActiveConnection *active = nm_device_get_active_connection (device);
NMActiveConnection *active = nm_device_get_active_connection (device);
if (nmc->print_output == NMC_PRINT_PRETTY)
nmc_terminal_erase_line ();
printf (_("Connection with UUID '%s' created and activated on device '%s'\n"),
nm_active_connection_get_uuid (active), nm_device_get_iface (device));
}
printf (_("Connection with UUID '%s' created and activated on device '%s'\n"),
nm_active_connection_get_uuid (active), nm_device_get_iface (device));
quit ();
} else if (state == NM_DEVICE_STATE_FAILED) {
g_string_printf (nmc->return_text, _("Error: Connection activation failed: (%d) %s."),
......@@ -1588,7 +1588,9 @@ add_and_activate_cb (NMClient *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 && nmc->print_output == NMC_PRINT_PRETTY) {
if (state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
if (nmc->print_output == NMC_PRINT_PRETTY)
nmc_terminal_erase_line ();
printf (_("Connection with UUID '%s' created and activated on device '%s'\n"),
nm_active_connection_get_uuid (active), nm_device_get_iface (device));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment