aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Winston2024-06-09 17:02:52 -0400
committerBen Winston2024-06-09 17:02:52 -0400
commitc6399d0c9716a8f1c4afc083ffabd19fc000aad4 (patch)
treeaeaf3c9a8c38294437a312f90ac2dae98a76013d
parentf07a38f116f9c8337955309b2d6065f145a1e9ac (diff)
add show flag to data points
-rw-r--r--booki.c24
1 files changed, 12 insertions, 12 deletions
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;