basic_kill,
basic_add,
basic_list,
+ basic_loop,
basic_remove,
+ basic_help,
} t_basic;
typedef struct s_command
command->entry.name = NULL;
if (argc == 1)
return (0);
- else if (argc == 2 && !ft_strcmp(argv[1], "-l"))
+ else if (argc == 2)
+ {
+ if (!ft_strcmp(argv[1], "-l"))
+ command->basic = basic_loop;
+ else if (!ft_strcmp(argv[1], "-h"))
+ command->basic = basic_help;
+ else
+ command->entry.name = argv[1];
+ return (0);
+ }
+ else if (argc == 2)
+ {
+ command->entry.name = argv[1];
return (0);
+ }
else if (argc == 3)
{
- if (ft_strcmp(argv[1], "-l") && ft_strcmp(argv[1], "-k") && ft_strcmp(argv[1], "-r"))
+ if (ft_strcmp(argv[1], "-k") && ft_strcmp(argv[1], "-r"))
return (1);
command->entry.name = argv[2];
if (argv[1][1] == 'k')
return (1);
}
+void print_help(void)
+{
+ static const char *helpstr =
+ "Palboss is a simple tracker of cooldown of bosses in Palworld\n"
+ "Usage:\tpalboss [option option_arguments]\n"
+ "\tWithout options it lists all the bosses\n"
+ "Options:\n"
+ "\tboss\n"
+ "\t\tPrint the info about the boss\n"
+ "\t-h\n"
+ "\t\tPrint this help.\n"
+ "\t-l\n"
+ "\t\tPrint the list in a loop. End by using Q key.\n"
+ "\t-k boss\n"
+ "\t\tMark the boss as killed, setting the counter to 60 minutes.\n"
+ "\t-a boss level location\n"
+ "\t\tAdd a boss to the database. Long strings may break formatting.\n"
+ "\t-r boss\n"
+ "\t\tRemove a boss from the database.\n";
+
+ ft_printf("%s", helpstr);
+ return ;
+}
+
void carry_out_command(t_command *com, t_vec *database)
{
size_t ind;
else
print_entry(ft_vec_access(database, ind));
}
- return ;
-}
-
-void print_help(void)
-{
- static const char *helpstr =
- "Palboss is a simple tracker of cooldown of bosses in Palworld\n"
- "Usage:\tpalboss [option option_arguments]\n"
- "\tWithout options it lists all the bosses\n"
- "Options:\n"
- "\t-l\n"
- "\t\tPrint the list in a loop. End by using Q key.\n"
- "\t-k boss\n"
- "\t\tMark the boss as killed, setting the counter to 60 minutes.\n"
- "\t-a boss level location\n"
- "\t\tAdd a boss to the database. Long strings may break formatting.\n"
- "\t-r boss\n"
- "\t\tRemove a boss from the database.\n";
-
- ft_printf("%s", helpstr);
+ else if (com->basic == basic_help)
+ print_help();
return ;
}