summaryrefslogtreecommitdiff
path: root/cli/mmcli-sim.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2018-10-27 14:46:38 +0200
committerAleksander Morgado <aleksander@aleksander.es>2018-11-20 09:20:13 +0100
commit855e7df12349087e8f2a3c24d003df1e83d8237e (patch)
tree11b3ee636787881c2d28742b29b50fcd65b301aa /cli/mmcli-sim.c
parent52a164d6c4c893852f286aa39252cb6abee8dde3 (diff)
downloadModemManager-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-sim.c')
-rw-r--r--cli/mmcli-sim.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/cli/mmcli-sim.c b/cli/mmcli-sim.c
index c8713743a..d31f07cba 100644
--- a/cli/mmcli-sim.c
+++ b/cli/mmcli-sim.c
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- * Copyright (C) 2011 Aleksander Morgado <aleksander@gnu.org>
+ * Copyright (C) 2011-2018 Aleksander Morgado <aleksander@aleksander.es>
*/
#include "config.h"
@@ -33,6 +33,7 @@
#include "mmcli.h"
#include "mmcli-common.h"
+#include "mmcli-output.h"
/* Context */
typedef struct {
@@ -157,22 +158,12 @@ mmcli_sim_shutdown (void)
static void
print_sim_info (MMSim *sim)
{
- /* Not the best thing to do, as we may be doing _get() calls twice, but
- * easiest to maintain */
-#undef VALIDATE
-#define VALIDATE(str) (str ? str : "unknown")
-
- g_print ("SIM '%s'\n",
- mm_sim_get_path (sim));
- g_print (" -------------------------\n"
- " Properties | imsi : '%s'\n"
- " | id : '%s'\n"
- " | operator id : '%s'\n"
- " | operator name : '%s'\n",
- VALIDATE (mm_sim_get_imsi (sim)),
- VALIDATE (mm_sim_get_identifier (sim)),
- VALIDATE (mm_sim_get_operator_identifier (sim)),
- VALIDATE (mm_sim_get_operator_name (sim)));
+ mmcli_output_string (MMC_F_SIM_GENERAL_DBUS_PATH, mm_sim_get_path (sim));
+ mmcli_output_string (MMC_F_SIM_PROPERTIES_IMSI, mm_sim_get_imsi (sim));
+ mmcli_output_string (MMC_F_SIM_PROPERTIES_ICCID, mm_sim_get_identifier (sim));
+ mmcli_output_string (MMC_F_SIM_PROPERTIES_OPERATOR_ID, mm_sim_get_operator_identifier (sim));
+ mmcli_output_string (MMC_F_SIM_PROPERTIES_OPERATOR_NAME, mm_sim_get_operator_name (sim));
+ mmcli_output_dump ();
}
static void