This commit is contained in:
Your Name 2024-01-03 13:18:43 +03:00
parent d63feaa864
commit 69ddc38152
5 changed files with 41 additions and 42 deletions

View file

@ -1,32 +1,28 @@
#define _MAIN_H
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
#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) {
while ((opt = getopt(argc, argv, "hld:")) != -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");
printf("kfetch [hl]\n\t[-h Help menu] [-l Dont print logo]\n\t[-d N Set N as distro name]\n");
return 0;
}
}
@ -34,7 +30,7 @@ int main(int argc, char **argv) {
FETCH fetch = Init();
if (d_flag != NULL) {
snprintf(fetch.os_name, sizeof(fetch.os_name), "%s", d_flag);
GetArt(&fetch);
GetArt(&fetch, 0);
}
int flag = 0;
@ -49,7 +45,7 @@ int main(int argc, char **argv) {
/* Strip */
char *title = CONFIG[i].title;
if (s_flag) {
if (l_flag) {
size_t len = strlen(title);
for (size_t i = 0; i < len; i++) {
if (title[0] != ' ')
@ -60,14 +56,14 @@ int main(int argc, char **argv) {
}
/* Function exec */
if (!CONFIG[i].func(title, fetch)) {
flag = 0;
printf("\033[0m\n");
if (CONFIG[i].func(title, fetch)) {
flag = 1;
printf("\033[0m");
}
else {
flag = 1;
printf("\033[0m");
flag = 0;
printf("\033[0m\n");
}
}