diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2018-10-27 14:46:38 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2018-11-20 09:20:13 +0100 |
commit | 855e7df12349087e8f2a3c24d003df1e83d8237e (patch) | |
tree | 11b3ee636787881c2d28742b29b50fcd65b301aa /cli/mmcli-modem-firmware.c | |
parent | 52a164d6c4c893852f286aa39252cb6abee8dde3 (diff) | |
download | ModemManager-aleksander/mmcli-output.tar.gz |
cli: allow multiple output format typesaleksander/mmcli-output
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.c | 46 |
1 files changed, 5 insertions, 41 deletions
diff --git a/cli/mmcli-modem-firmware.c b/cli/mmcli-modem-firmware.c index 0905a00c6..008de8dea 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 |