commit 9693a8c486944835b8eb8a6ba52b41b1d5ef32e7
parent 028be083bbd82237b40c65d237eeb0dc77e4f465
Author: nibo <nibo@relim.de>
Date: Wed, 7 Aug 2024 11:04:32 +0200
Fix --print-default-config
Diffstat:
| M | config.c | | | 36 | ++++++++++++++++++++++++++++++++++++ |
| M | todo | | | 1 | + |
2 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/config.c b/config.c
@@ -196,6 +196,28 @@ static struct Note **config_notes_load(toml_table_t *notes, const char *system)
return NULL;
}
+static const char *config_parse_mode_to_string(enum ParseMode mode)
+{
+ if (mode == PM_RELAXED) {
+ return "relaxed";
+ }
+ return "strict";
+}
+
+static const char *config_naming_system_to_string(enum NamingSystem system)
+{
+ switch (system) {
+ case NS_GERMAN:
+ return "german";
+ case NS_SCANDINAVIAN:
+ return "scandinavian";
+ case NS_LATIN:
+ return "latin";
+ default:
+ return "common";
+ }
+}
+
static struct Config *config_load_default(void)
{
struct Config *config = malloc(sizeof(struct Config));
@@ -247,12 +269,26 @@ static void config_printable_item_print_as_toml(struct PrintableItem *item)
void config_print_default(void)
{
struct Config *config = config_load_default();
+ config->chords->notes = config_notes_new_default(config->chords->system);
int i = 0;
printf("[styles]\n");
while (config->printable_items[i] != NULL) {
config_printable_item_print_as_toml(config->printable_items[i]);
i++;
}
+ printf("[chords]\n\n");
+ printf("mode = \"%s\"\n", config_parse_mode_to_string(config->chords->mode));
+ printf("system = \"%s\"\n\n", config_naming_system_to_string(config->chords->system));
+ printf("[chords.notes]\n\n");
+ printf("common = [\n");
+ printf("\t{ note = \"C\", sharp = \"C#\" },\n");
+ printf("\t{ note = \"D\", sharp = \"D#\", flat = \"Db\" },\n");
+ printf("\t{ note = \"E\", flat = \"Eb\" },\n");
+ printf("\t{ note = \"F\", sharp = \"F#\" },\n");
+ printf("\t{ note = \"G\", sharp = \"G#\", flat = \"Gb\" },\n");
+ printf("\t{ note = \"A\", sharp = \"A#\", flat = \"Ab\" },\n");
+ printf("\t{ note = \"B\", flat = \"Bb\" }\n");
+ printf("]\n");
config_free(config);
}
diff --git a/todo b/todo
@@ -14,3 +14,4 @@ introduce parse errors
still very unclear to me when the parser should warn
and continue execution and when it should fail and
stop execution
+*_to_string functions sometimes return stringified enum and sometimes config value