aboutsummaryrefslogtreecommitdiff
path: root/include/cli.h
diff options
context:
space:
mode:
authorSimon Glass2023-10-01 19:13:17 -0600
committerTom Rini2023-10-11 15:43:54 -0400
commit39ee32166f607d4e30a74d46f82adb39e4134ec4 (patch)
treed1540a98ede7f11262f6f82054d080299437e182 /include/cli.h
parent3b487bf51115bfb9a0f85667a5608fc57788107c (diff)
cli: Add a function to set up a new cread
Create a init function so that it is easy to use command-line reading. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/cli.h')
-rw-r--r--include/cli.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/include/cli.h b/include/cli.h
index ad3cb4499fe..e183d561369 100644
--- a/include/cli.h
+++ b/include/cli.h
@@ -32,7 +32,8 @@ struct cli_ch_state {
* @eol_num: Number of characters in the buffer
* @insert: true if in 'insert' mode
* @history: true if history should be accessible
- * @cmd_complete: true if tab completion should be enabled
+ * @cmd_complete: true if tab completion should be enabled (requires @prompt to
+ * be set)
* @buf: Buffer containing line
* @prompt: Prompt for the line
*/
@@ -262,6 +263,20 @@ int cli_ch_process(struct cli_ch_state *cch, int ichar);
*/
int cread_line_process_ch(struct cli_line_state *cls, char ichar);
+/**
+ * cli_cread_init() - Set up a new cread struct
+ *
+ * Sets up a new cread state, with history and cmd_complete set to false
+ *
+ * After calling this, you can use cread_line_process_ch() to process characters
+ * received from the user.
+ *
+ * @cls: CLI line state
+ * @buf: Text buffer containing the initial text
+ * @buf_size: Buffer size, including nul terminator
+ */
+void cli_cread_init(struct cli_line_state *cls, char *buf, uint buf_size);
+
/** cread_print_hist_list() - Print the command-line history list */
void cread_print_hist_list(void);