diff options
| author | ThomasintAnker <thomasintanker1@gmail.com> | 2024-05-31 15:06:06 +0200 |
|---|---|---|
| committer | ThomasintAnker <thomasintanker1@gmail.com> | 2024-05-31 15:06:06 +0200 |
| commit | 0278037aaf3fd497aae57d90f2638ceda3b12a6d (patch) | |
| tree | 3354a14d4551b9524108d02971bfa42fc1ad4993 /client/cmd.h | |
| parent | b865921e5dcf2ae2d6532b88eba1a0a49998eb27 (diff) | |
| parent | 18d06c79b9f6a625eb218a15c8216556fb99dc02 (diff) | |
Merge branch 'wip/client' into wip/i2c-communication
Diffstat (limited to 'client/cmd.h')
| -rw-r--r-- | client/cmd.h | 74 |
1 files changed, 43 insertions, 31 deletions
diff --git a/client/cmd.h b/client/cmd.h index 9d20328..961ef89 100644 --- a/client/cmd.h +++ b/client/cmd.h @@ -2,59 +2,71 @@ #include <stddef.h> -typedef void cmd_fn_t(char *); +typedef void cmd_handle_t(char *); +typedef char** cmd_complete_t(const char*, int, int); struct cmd { - void (* handle)(char *); + cmd_handle_t * handle; const char* name; const char* info; - // TODO: tab completion function? + cmd_complete_t * complete; }; +typedef struct cmd cmd_t; -cmd_fn_t cmd_exit; -cmd_fn_t cmd_test; -cmd_fn_t cmd_help; -cmd_fn_t cmd_send; -cmd_fn_t cmd_status; -cmd_fn_t cmd_reset; -cmd_fn_t cmd_ls; +cmd_handle_t cmd_exit; +cmd_handle_t cmd_test; +cmd_handle_t cmd_help; +cmd_handle_t cmd_reset; +cmd_handle_t cmd_ls; +cmd_handle_t cmd_send; +cmd_handle_t cmd_skip; +cmd_handle_t cmd_dump; +cmd_complete_t cmd_dump_complete; -static const struct cmd cmds[] = { +static const cmd_t cmds[] = { { .handle = cmd_exit, .name = "exit", .info = "exit pbc", }, { - .handle = cmd_test, - .name = "test", - .info = "send a test puzbus message", - }, - { .handle = cmd_help, .name = "help", .info = "show this help", }, { + .handle = cmd_reset, + .name = "reset", + .info = "set game state to 'idle' for one or more puzzle modules", + }, + { + .handle = cmd_skip, + .name = "skip", + .info = "set game state to 'solved' for one or more puzzle modules", + }, + { + .handle = cmd_ls, + .name = "ls", + .info = "list connected puzzle modules and their state", + }, +#ifdef DEBUG + { .handle = cmd_send, .name = "send", .info = "[debug] send raw message", }, - // { - // .handle = cmd_status, - // .name = "status", - // .info = "show global puzzle box state (main controller state)", - // }, - // { - // .handle = cmd_reset, - // .name = "reset", - // .info = "reset entire game state", - // }, - // { - // .handle = cmd_ls, - // .name = "ls", - // .info = "list connected puzzle modules", - // }, + { + .handle = cmd_test, + .name = "test", + .info = "[debug] send a test puzbus message", + }, + { + .handle = cmd_dump, + .name = "dump", + .info = "[debug] dump sent or received messages", + .complete = cmd_dump_complete, + }, +#endif }; static const size_t cmds_length = sizeof(cmds) / sizeof(cmds[0]); |