🏗️」 wip: parsing kinda working

This commit is contained in:
2025-08-11 21:52:57 +02:00
parent 8f1abd7940
commit e635977c88
6 changed files with 105 additions and 41 deletions

View File

@ -4,36 +4,48 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
int handle_long_args(char **av, args_t *args) {
OPT_WHILE {
if (strncmp((*av) + 2, options[i].name, strlen(options[i].name)) == 0) {
OPT_HANDLE(i)
}
i++;
}
return EXIT_SUCCESS;
}
int opt_parse(char **av, args_t *args) {
char *exec_name = *av;
(void)args;
while (*av != NULL) {
char *a = *av;
if (*a == '-') {
switch ((char)*(a + 1)) {
case '-':
break;
case '?':
print_help();
return -1;
case 'v':
printf("verboseeee");
break;
};
char opt = *(a + 1);
if (!opt) {
print_no_host(exec_name);
return EX_USAGE;
} else if (opt == '-') {
int ret = handle_long_args(av, args);
if (ret == EX_USAGE) {
print_no_host(exec_name);
return EX_USAGE;
}
} else {
OPT_WHILE {
if (opt == options[i].opt) {
OPT_HANDLE(i)
}
i++;
}
}
} else {
}
av++;
}
if (av) {
print_no_host(exec_name);
return EX_USAGE;
}
return EXIT_SUCCESS;
}