#define _MAIN_H #include #include #include "fetch.h" #include "config.h" int main(int argc, char **argv) { unsigned int l_flag = 0; unsigned int s_flag = 0; char *d_flag = NULL; int opt; while ((opt = getopt(argc, argv, "hlsd:")) != -1) { switch (opt) { case 'l': l_flag = 1; break; case 's': s_flag = 1; break; case 'd': d_flag = optarg; break; case 'h': default: printf("kfetch [hl]\n\t[-h Help menu] [-s Strip lines]\n\t[-l Dont print logo]\n\t[-d N Set N as distro name]\n"); return 0; } } FETCH fetch = Init(); if (d_flag != NULL) { snprintf(fetch.os_name, sizeof(fetch.os_name), "%s", d_flag); GetArt(&fetch); } int flag = 0; size_t i = 0; for (i = 0; i < sizeof(CONFIG) / sizeof(PARAMETR); i++) { /* Logo print */ if (i < fetch.logo_size && !flag && !l_flag) printf("%s", fetch.logo[i]); else if (i >= fetch.logo_size && !flag && !l_flag) printf("%s", fetch.logo[fetch.logo_size - 1]); /* Strip */ char *title = CONFIG[i].title; if (s_flag) { size_t len = strlen(title); for (size_t i = 0; i < len; i++) { if (title[0] != ' ') break; title++; } } /* Function exec */ if (!CONFIG[i].func(title, fetch)) { flag = 0; printf("\033[0m\n"); } else { flag = 1; printf("\033[0m"); } } for (; i < fetch.logo_size; i++) printf("%s\n", fetch.logo[i]); printf("\033[0m"); return 0; }