[libosinfo PATCH 2/3] osinfo-query: Add real_prop to OsinfoLabel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



real_prop is going to be used to map a command-line option to a real
option whenever we're dealing with sub-properties that happen to have
the very same name as a property that's already taken into
consideration.

One example of this is when getting os variants. For this we'd need to
get OsVariant::name, while we already search for Os::name. In order to
solve this ambiguity, let's have a name that we can expose to the
command line a and the real_prop that we could get whenever it's needed.

https://gitlab.com/libosinfo/libosinfo/issues/24

Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 tools/osinfo-query.c | 63 ++++++++++++++++++++++----------------------
 1 file changed, 32 insertions(+), 31 deletions(-)

diff --git a/tools/osinfo-query.c b/tools/osinfo-query.c
index 045f3c1..dff2bd7 100644
--- a/tools/osinfo-query.c
+++ b/tools/osinfo-query.c
@@ -36,6 +36,7 @@ typedef OsinfoList * (*osinfo_os_list_func)(OsinfoOs *os);
 
 struct OsinfoLabel {
     const gchar *prop;
+    const gchar *real_prop;
     const gchar *label;
     gboolean enabled;
     gsize width;
@@ -54,73 +55,73 @@ struct OsinfoType {
 };
 
 static struct OsinfoLabel os_labels[] = {
-    { OSINFO_PRODUCT_PROP_SHORT_ID,
+    { OSINFO_PRODUCT_PROP_SHORT_ID, NULL,
       N_("Short ID"), TRUE, 20, NULL },
-    { OSINFO_PRODUCT_PROP_NAME,
+    { OSINFO_PRODUCT_PROP_NAME, NULL,
       N_("Name"), TRUE, 50, NULL },
-    { OSINFO_PRODUCT_PROP_VERSION,
+    { OSINFO_PRODUCT_PROP_VERSION, NULL,
       N_("Version"), TRUE, 8, NULL },
-    { OSINFO_OS_PROP_FAMILY,
+    { OSINFO_OS_PROP_FAMILY, NULL,
       N_("Family"), FALSE, 12, NULL },
-    { OSINFO_OS_PROP_DISTRO,
+    { OSINFO_OS_PROP_DISTRO, NULL,
       N_("Distro"), FALSE, 12, NULL },
-    { OSINFO_PRODUCT_PROP_VENDOR,
+    { OSINFO_PRODUCT_PROP_VENDOR, NULL,
       N_("Vendor"), FALSE, 25, NULL },
-    { OSINFO_PRODUCT_PROP_RELEASE_DATE,
+    { OSINFO_PRODUCT_PROP_RELEASE_DATE, NULL,
       N_("Release date"), FALSE, 12, NULL },
-    { OSINFO_PRODUCT_PROP_EOL_DATE,
+    { OSINFO_PRODUCT_PROP_EOL_DATE, NULL,
       N_("End of life"), FALSE, 12, NULL },
-    { OSINFO_PRODUCT_PROP_CODENAME,
+    { OSINFO_PRODUCT_PROP_CODENAME, NULL,
       N_("Code name"), FALSE, 10, NULL },
-    { OSINFO_ENTITY_PROP_ID,
+    { OSINFO_ENTITY_PROP_ID, NULL,
       N_("ID"), TRUE, 40, NULL },
-    { NULL, NULL, 0, 0, NULL}
+    { NULL, NULL, NULL, 0, 0, NULL}
 };
 
 static struct OsinfoLabel platform_labels[] = {
-    { OSINFO_PRODUCT_PROP_SHORT_ID,
+    { OSINFO_PRODUCT_PROP_SHORT_ID, NULL,
       N_("Short ID"), TRUE, 20, NULL },
-    { OSINFO_PRODUCT_PROP_NAME,
+    { OSINFO_PRODUCT_PROP_NAME, NULL,
       N_("Name"), TRUE, 50, NULL },
-    { OSINFO_PRODUCT_PROP_VERSION,
+    { OSINFO_PRODUCT_PROP_VERSION, NULL,
       N_("Version"), TRUE, 8, NULL },
-    { OSINFO_PRODUCT_PROP_VENDOR,
+    { OSINFO_PRODUCT_PROP_VENDOR, NULL,
       N_("Vendor"), TRUE, 25, NULL },
-    { OSINFO_PRODUCT_PROP_RELEASE_DATE,
+    { OSINFO_PRODUCT_PROP_RELEASE_DATE, NULL,
       N_("Release date"), FALSE, 12, NULL },
-    { OSINFO_PRODUCT_PROP_EOL_DATE,
+    { OSINFO_PRODUCT_PROP_EOL_DATE, NULL,
       N_("End of life"), FALSE, 12, NULL },
-    { OSINFO_PRODUCT_PROP_CODENAME,
+    { OSINFO_PRODUCT_PROP_CODENAME, NULL,
       N_("Code name"), FALSE, 10, NULL },
-    { OSINFO_ENTITY_PROP_ID,
+    { OSINFO_ENTITY_PROP_ID, NULL,
       N_("ID"), TRUE, 40, NULL },
-    { NULL, NULL, 0, 0, NULL },
+    { NULL, NULL, NULL, 0, 0, NULL },
 };
 
 static struct OsinfoLabel device_labels[] = {
-    { OSINFO_DEVICE_PROP_VENDOR,
+    { OSINFO_DEVICE_PROP_VENDOR, NULL,
       N_("Vendor"), TRUE, 20, NULL },
-    { OSINFO_DEVICE_PROP_VENDOR_ID,
+    { OSINFO_DEVICE_PROP_VENDOR_ID, NULL,
       N_("Vendor ID"), TRUE, 12, NULL },
-    { OSINFO_DEVICE_PROP_PRODUCT,
+    { OSINFO_DEVICE_PROP_PRODUCT, NULL,
       N_("Product"), TRUE, 20 ,NULL },
-    { OSINFO_DEVICE_PROP_PRODUCT_ID,
+    { OSINFO_DEVICE_PROP_PRODUCT_ID, NULL,
       N_("Product ID"), TRUE, 12, NULL },
-    { OSINFO_PRODUCT_PROP_NAME,
+    { OSINFO_PRODUCT_PROP_NAME, NULL,
       N_("Name"), TRUE, 14, NULL },
-    { OSINFO_DEVICE_PROP_CLASS,
+    { OSINFO_DEVICE_PROP_CLASS, NULL,
       N_("Class"), TRUE, 15, NULL },
-    { OSINFO_DEVICE_PROP_BUS_TYPE,
+    { OSINFO_DEVICE_PROP_BUS_TYPE, NULL,
       N_("Bus"), TRUE, 8, NULL },
-    { OSINFO_ENTITY_PROP_ID,
+    { OSINFO_ENTITY_PROP_ID, NULL,
       N_("ID"), TRUE, 40, NULL },
-    { NULL, NULL, 0, 0, NULL },
+    { NULL, NULL, NULL, 0, 0, NULL },
 };
 
 static struct OsinfoLabel deployment_labels[] = {
-    { OSINFO_ENTITY_PROP_ID,
+    { OSINFO_ENTITY_PROP_ID, NULL,
       N_("ID"), TRUE, 40, NULL },
-    { NULL, NULL, 0, 0, NULL },
+    { NULL, NULL, NULL, 0, 0, NULL },
 };
 
 
-- 
2.20.1

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux