NetworkManager/clients/cli
Thomas Haller fdd40b6a68 cli: implement new nmc_print() command to generically output cli data
We already have
  - data sources (nm_cli, connections or settings)
  - meta data information how to access the data sources (NMMetaAbstractInfo,
    NmcMetaGenericInfo, NMMetaPropertyInfo)

Add now a generic way to output cli data using nmc_print(). It gets a
list of data-sources (@targets) and a list of available fields (meta
data). It also gets cli configuration (NmcConfig) and field selector
strings (@field_str).

Based on that, it should output the desired data.

This is intended to replaces the previous approach, where functions like
show_nm_status() have full knowledge about how to access the data and
create an intermediate output format (NmcOutputData, NmcOutputField)
that was printed via print_data().
show_nm_status() contained both knowledge about the data itself (how to
print a value) and intimate knoweledge about the output intermediate
format. Also, the intermediate format is hard to understand. For
example, sometimes we put the field prefix in NmcOutputField at index 0
and via the NmcOfFlags we control how to output the data.

Clearly separate the responsibilities.

  - The meta data (NmcMetaGenericInfo) is only concerned with converting
    a data source to a string (or a color format).
  - the field selection (@field_str) only cares about parsing the list
    of NMMetaAbstractInfo.
  - _print_fill() populates a table with output values and header
    entries.
  - _print_do() prints the previously prepared table.

The advantage is that if you want to change anything, you only need to
touch a particular part.

This is only a show-case for `nmcli general status`. Parts are still
un-implemented and will follow.

This changes behavior for --terse mode: the values are now no longer
translated:
  $ LANG=de_DE.utf8 nmcli -t --mode multiline general
2017-04-12 11:24:04 +02:00
..
agent.c cli: move NmcMetaGenericInfo to "utils.h" 2017-04-05 16:53:06 +02:00
agent.h cli: add 'nmcli agent' command (bgo #739568) 2014-11-07 11:58:25 +01:00
common.c cli: move NmcMetaGenericInfo to "utils.h" 2017-04-05 16:53:06 +02:00
common.h cli: split tracking of meta data out of NmcOutputField 2017-04-05 16:53:06 +02:00
connections.c cli: implement new nmc_print() command to generically output cli data 2017-04-12 11:24:04 +02:00
connections.h cli: move and rename TermColor and TermFormat 2017-04-05 16:53:06 +02:00
devices.c nmcli: fix "nmcli device monitor <dev>" 2017-04-11 15:49:30 +02:00
devices.h cli: move and rename TermColor and TermFormat 2017-04-05 16:53:06 +02:00
general.c cli: implement new nmc_print() command to generically output cli data 2017-04-12 11:24:04 +02:00
general.h cli: output a short summary of devices when called without arguments 2016-07-19 14:29:05 +02:00
nmcli-completion cli: make nmcli do its own command completion 2017-02-13 16:32:15 +01:00
nmcli.c cli: move and rename TermColor and TermFormat 2017-04-05 16:53:06 +02:00
nmcli.h cli: move and rename TermColor and TermFormat 2017-04-05 16:53:06 +02:00
polkit-agent.c cli: move NmcMetaGenericInfo to "utils.h" 2017-04-05 16:53:06 +02:00
polkit-agent.h cli: add 'nmcli agent' command (bgo #739568) 2014-11-07 11:58:25 +01:00
settings.c cli: do not show description of unsupported properties 2017-04-12 10:18:01 +02:00
settings.h cli: move NmcMetaGenericInfo to "utils.h" 2017-04-05 16:53:06 +02:00
utils.c cli: implement new nmc_print() command to generically output cli data 2017-04-12 11:24:04 +02:00
utils.h cli: implement new nmc_print() command to generically output cli data 2017-04-12 11:24:04 +02:00