#pragma once

#include "myBase.h"

typedef struct
{
    const char *name;
    void (*func)(int argc, char *argv[]);
    const char *desc;
}stru_cmd;


#define CMD_REGISTER(cmd_name, func_ptr, cmd_desc) \
    __attribute__((constructor)) static void register_##func_ptr(void) { \
        cmd_manager_add_command(cmd_name, func_ptr, cmd_desc); \
    }

void cmd_manager_add_command(const char *name, void (*func)(int argc, char *argv[]), const char *desc);


stru_cmd *cmd_manager_get_commands(unsigned int *out_count);

void cmd_help(int argc, char *argv[]);
stru_cmd *cmd_find(const char *name);
void cmd_complete(const char *buf, char ***completions, int *ncomp);


char *linenoise(const char *prompt);
void linenoiseFree(void *ptr);
int linenoiseHistoryAdd(const char *line);
void linenoiseHistoryFree(void);
void lineniseSetCompletionCallback(void (*cb)(const char *, char ***, int *));
