From c6399d0c9716a8f1c4afc083ffabd19fc000aad4 Mon Sep 17 00:00:00 2001 From: Ben Winston Date: Sun, 9 Jun 2024 17:02:52 -0400 Subject: add show flag to data points --- booki.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'booki.c') diff --git a/booki.c b/booki.c index 8d81d14..32602ca 100644 --- a/booki.c +++ b/booki.c @@ -20,18 +20,19 @@ typedef struct DataField DataField; struct DataField { char* name; enum DataType type; + bool show; }; static const DataField BOOK_FIELDS[] = { - { "title", booki_string }, - { "author", booki_string }, - { "isbn", booki_string }, - { "pages", booki_number }, - { "published", booki_number }, - { "language", booki_string }, - { "translator", booki_string }, - { "on", booki_string }, - { "id", booki_number } + { "title", booki_string, true }, + { "author", booki_string, true }, + { "isbn", booki_string, true }, + { "pages", booki_number, true }, + { "published", booki_number, true }, + { "language", booki_string, true }, + { "translator", booki_string, true }, + { "on", booki_string, true }, + { "id", booki_number, false } }; #define BOOK_FIELDS_COUNT (sizeof(BOOK_FIELDS) / sizeof(BOOK_FIELDS[0])) @@ -460,6 +461,8 @@ void print_book(BOOK book, bool all_fields) { int number_field; for (int i = 2; i < BOOK_FIELDS_COUNT; i++) { datafield = BOOK_FIELDS[i]; + if (!datafield.show) + continue; // string fields if (datafield.type == booki_string) { @@ -471,9 +474,6 @@ void print_book(BOOK book, bool all_fields) { printf(esfmt, datafield.name, size, str); // number fields } else if (datafield.type == booki_number) { - // don't print the ID - if (ATTR_MATCH(datafield.name, "id")) - continue; number_field = get_number_field(book, datafield.name); if (!number_field) continue; -- cgit v1.2.3