aboutsummaryrefslogtreecommitdiff
path: root/cli/mmcli-modem-firmware.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2018-10-27 14:46:38 +0200
committerDan Williams <dcbw@redhat.com>2018-11-26 16:51:35 +0000
commitb0fba14b1e122522a1db2581779ffb94ee7cfa37 (patch)
treef0ab362f9e124b7f01f8c7e1b97a84d0c40f3edc /cli/mmcli-modem-firmware.c
parentcafc40245d2007ad3a9a33875fc6b71d25e6a254 (diff)
cli: allow multiple output format types
In addition to the standard human-friendly output, we now allow a machine-friendly key-value pair output, much easier to parse and use by programs that look at the mmcli output. This new key-value pair output should be treated as API from now on, so third-party programs can assume the output is compatible from one release to another.
Diffstat (limited to 'cli/mmcli-modem-firmware.c')
-rw-r--r--cli/mmcli-modem-firmware.c46
1 files changed, 5 insertions, 41 deletions
diff --git a/cli/mmcli-modem-firmware.c b/cli/mmcli-modem-firmware.c
index 0905a00c..008de8de 100644
--- a/cli/mmcli-modem-firmware.c
+++ b/cli/mmcli-modem-firmware.c
@@ -33,6 +33,7 @@
#include "mmcli.h"
#include "mmcli-common.h"
+#include "mmcli-output.h"
/* Context */
typedef struct {
@@ -143,48 +144,11 @@ list_process_reply (MMFirmwareProperties *selected,
exit (EXIT_FAILURE);
}
- g_print ("\n");
- if (!result) {
- g_print ("No firmware images were found\n");
- } else {
- GList *l;
- guint i;
-
- g_print ("Found %u firmware images:\n", g_list_length (result));
- for (l = result, i = 0; l; l = g_list_next (l), i++) {
- MMFirmwareProperties *props = MM_FIRMWARE_PROPERTIES (l->data);
-
- g_print ("\t[%u] %s%s\n"
- "\t\tType: '%s'\n",
- i,
- mm_firmware_properties_get_unique_id (props),
- ((selected &&
- g_str_equal (mm_firmware_properties_get_unique_id (props),
- mm_firmware_properties_get_unique_id (selected))) ?
- " (CURRENT)" : ""),
- mm_firmware_image_type_get_string (
- mm_firmware_properties_get_image_type (props)));
-
- if (mm_firmware_properties_get_image_type (props) == MM_FIRMWARE_IMAGE_TYPE_GOBI) {
- g_print ("\t\t[Gobi] PRI version: '%s'\n"
- "\t\t[Gobi] PRI info: '%s'\n"
- "\t\t[Gobi] Boot version: '%s'\n"
- "\t\t[Gobi] PRI Unique ID: '%s'\n"
- "\t\t[Gobi] Modem Unique ID: '%s'\n",
- VALIDATE_UNKNOWN (mm_firmware_properties_get_gobi_pri_version (props)),
- VALIDATE_UNKNOWN (mm_firmware_properties_get_gobi_pri_info (props)),
- VALIDATE_UNKNOWN (mm_firmware_properties_get_gobi_boot_version (props)),
- VALIDATE_UNKNOWN (mm_firmware_properties_get_gobi_pri_unique_id (props)),
- VALIDATE_UNKNOWN (mm_firmware_properties_get_gobi_modem_unique_id (props)));
- }
-
- g_object_unref (props);
- }
- g_list_free (result);
- }
+ mmcli_output_firmware_list (result, selected);
+ mmcli_output_dump ();
- if (selected)
- g_object_unref (selected);
+ g_list_free_full (result, g_object_unref);
+ g_clear_object (&selected);
}
static void