aboutsummaryrefslogtreecommitdiff
path: root/client/cmd.h
diff options
context:
space:
mode:
authorElwin Hammer <elwinhammer@gmail.com>2024-06-22 22:32:30 +0200
committerGitHub <noreply@github.com>2024-06-22 22:32:30 +0200
commita9eb2013e6b7297cfce4116179f4ab2d58d1c8d6 (patch)
tree0f16b75795d9926c5ea4a8ef52a695365837a8e4 /client/cmd.h
parentf121de7c7e3ca8f0dc526973a5ee2586485aad22 (diff)
parentd6440954806d381dae5b3df65b43192f897018c6 (diff)
Merge pull request #21 from lonkaars/master
Updating branch
Diffstat (limited to 'client/cmd.h')
-rw-r--r--client/cmd.h50
1 files changed, 41 insertions, 9 deletions
diff --git a/client/cmd.h b/client/cmd.h
index 961ef89..a3cc44a 100644
--- a/client/cmd.h
+++ b/client/cmd.h
@@ -1,17 +1,44 @@
#pragma once
+/**
+ * \ingroup pbc
+ * \defgroup pbc_cmd cmd
+ * \brief Commands within \ref pbc
+ * \{
+ */
+
#include <stddef.h>
-typedef void cmd_handle_t(char *);
-typedef char** cmd_complete_t(const char*, int, int);
+/**
+ * \internal
+ * \brief Command handler function
+ *
+ * \param line Remaining text after command name on command line
+ */
+typedef void cmd_handle_t(char * line);
+/**
+ * \internal
+ * \brief Command completion function
+ *
+ * \param text Current word to complete
+ * \param start Index in \c rl_line_buffer of cursor position
+ * \param end End index of \p text in \c rl_line_buffer
+ *
+ * \return Array of \c char* with suggestions. The array is terminated by a
+ * NULL pointer.
+ */
+typedef char** cmd_complete_t(const char* text, int start, int end);
-struct cmd {
- cmd_handle_t * handle;
- const char* name;
- const char* info;
- cmd_complete_t * complete;
-};
-typedef struct cmd cmd_t;
+/**
+ * \internal
+ * \brief Command definition struct
+ */
+typedef struct {
+ cmd_handle_t * handle; //!< Handler function (required)
+ const char* name; //!< Command name (required)
+ const char* info; //!< Command info (shown in help command) (optional = NULL)
+ cmd_complete_t * complete; //!< Completion function (optional = NULL)
+} cmd_t;
cmd_handle_t cmd_exit;
cmd_handle_t cmd_test;
@@ -23,6 +50,7 @@ cmd_handle_t cmd_skip;
cmd_handle_t cmd_dump;
cmd_complete_t cmd_dump_complete;
+//! Commands
static const cmd_t cmds[] = {
{
.handle = cmd_exit,
@@ -68,5 +96,9 @@ static const cmd_t cmds[] = {
},
#endif
};
+
+//! Number of commands defined in \c cmds
static const size_t cmds_length = sizeof(cmds) / sizeof(cmds[0]);
+/// \}
+