feat(parsing/sources): adding the exception if no args provided
This commit is contained in:
parent
144637684f
commit
5944b16609
1 changed files with 13 additions and 1 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/03/23 14:49:36 by rparodi #+# #+# */
|
||||
/* Updated: 2026/03/28 15:26:13 by rparodi ### ########.fr */
|
||||
/* Updated: 2026/03/28 15:43:45 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -60,6 +60,10 @@ static struct option *_t_args_to_getopt_long(const size_t size) {
|
|||
|
||||
void parsing_args(int argc, char **argv, t_flags *flags)
|
||||
{
|
||||
if (argc == 1) {
|
||||
dprintf(2, "%s: missing host operand \n Try 'ping --help' or 'ping --usage' for more information.", argv[0]);
|
||||
exit(64);
|
||||
}
|
||||
const size_t size = args_size();
|
||||
size_t j = 0;
|
||||
char args[2 * size + 1];
|
||||
|
|
@ -127,6 +131,14 @@ void parsing_args(int argc, char **argv, t_flags *flags)
|
|||
default:
|
||||
if (strcmp(options[optind - 1].name, "usage"))
|
||||
print_usage(size);
|
||||
else {
|
||||
if (isprint(optopt)) {
|
||||
char invalid_option[2] = {optopt, 0};
|
||||
WARN_LOG(invalid_option);
|
||||
}
|
||||
dprintf(2, "Try 'ping --help' or 'ping --usage' for more information.\n");
|
||||
exit(64);
|
||||
}
|
||||
}
|
||||
}
|
||||
free(options);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue