🔨」 fix: fixed issue with init and cleaned help print

This commit is contained in:
2025-08-11 22:07:37 +02:00
parent e635977c88
commit 173e8a122a
3 changed files with 45 additions and 15 deletions

View File

@ -2,6 +2,7 @@
#include <stdint.h>
#include <stdio.h>
#include <string.h>
void print_help(void) {
printf("Usage: ping [OPTION...] HOST ...\n");
@ -9,24 +10,40 @@ void print_help(void) {
printf(" All the mandatory options : \n");
OPT_WHILE {
if (options[i].grp == 1)
printf(" -%c, --%s:\t %s\n", options[i].opt, options[i].name,
options[i].doc);
if (options[i].grp == 1) {
if (strlen(options[i].name) > 5)
printf(" -%c, --%s:\t %s\n", options[i].opt, options[i].name,
options[i].doc);
else
printf(" -%c, --%s:\t\t %s\n", options[i].opt, options[i].name,
options[i].doc);
}
i++;
}
printf("\n All the bonuses options : \n");
i = 0;
printf(" All the bonuses options : \n");
while (i < OPT_NB) {
if (options[i].grp == 2)
printf(" -%c, --%s:\t %s\n", options[i].opt, options[i].name,
options[i].doc);
if (options[i].grp == 2) {
if (strlen(options[i].name) > 5)
printf(" -%c, --%s:\t %s\n", options[i].opt, options[i].name,
options[i].doc);
else
printf(" -%c, --%s:\t\t %s\n", options[i].opt, options[i].name,
options[i].doc);
}
i++;
}
printf(" All the prints and help function : \n");
printf("\n All the prints and help function : \n");
i = 0;
while (i < OPT_NB) {
if (options[i].grp == 0)
printf(" -%c, --%s:\t %s\n", options[i].opt, options[i].name,
options[i].doc);
if (options[i].grp == 0) {
if (strlen(options[i].name) > 5)
printf(" -%c, --%s:\t %s\n", options[i].opt, options[i].name,
options[i].doc);
else
printf(" -%c, --%s:\t\t %s\n", options[i].opt, options[i].name,
options[i].doc);
}
i++;
}
printf(