diff --git a/src/main.c b/src/main.c index f8dd4c0..c87787b 100644 --- a/src/main.c +++ b/src/main.c @@ -25,6 +25,18 @@ int main(int argc, char *argv[]) { char *config_path = default_config_path(); + FILE *config_file = fopen(config_path, "r"); + + if (config_file == NULL) { + fprintf(stderr, "error: failed to open config at: %s\n", config_path); + exit(EXIT_FAILURE); + } + + Config config = parse_config(config_file); + + fclose(config_file); + free(config_path); + for (size_t i = 1; i < (size_t)argc; ++i) { if (strcmp(argv[i], "-c") == 0 || strcmp(argv[i], "--config") == 0) { if (i == (size_t)argc - 1) { @@ -47,18 +59,6 @@ int main(int argc, char *argv[]) { } } - FILE *config_file = fopen(config_path, "r"); - - if (config_file == NULL) { - fprintf(stderr, "error: failed to open config at: %s\n", config_path); - exit(EXIT_FAILURE); - } - - Config config = parse_config(config_file); - - fclose(config_file); - free(config_path); - fetch(config); return 0;