shell: Added noprompt command
Added noprompt command to shell. It will disable printing the prompt. For the native port, when feeding commands from a file or pipe the prompt reprinting after each command (without echoing) just confuses the user. Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
This commit is contained in:
parent
6ef85ed6fc
commit
bfabdf1de5
2 changed files with 24 additions and 4 deletions
|
@ -53,6 +53,14 @@ Select module commands
|
|||
``select``
|
||||
Clears selected module. Restores prompt as well.
|
||||
|
||||
Other commands
|
||||
==============
|
||||
|
||||
``noprompt``
|
||||
This command will disable the shell prompt. The shell will still be fully
|
||||
functional, but the prompt will not be printed each time the shell expects a
|
||||
new command.
|
||||
|
||||
Shell configuration
|
||||
*******************
|
||||
There are two levels of configuration: Infrastructure level and Module level.
|
||||
|
|
|
@ -51,6 +51,7 @@ extern struct shell_cmd __shell_cmd_end[];
|
|||
static const char *prompt;
|
||||
static char default_module_prompt[PROMPT_MAX_LEN];
|
||||
static struct shell_module *default_module;
|
||||
static bool no_promt;
|
||||
|
||||
#define STACKSIZE CONFIG_CONSOLE_SHELL_STACKSIZE
|
||||
static K_THREAD_STACK_DEFINE(stack, STACKSIZE);
|
||||
|
@ -338,6 +339,16 @@ static int cmd_exit(int argc, char *argv[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int cmd_noprompt(int argc, char *argv[])
|
||||
{
|
||||
no_promt = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define SHELL_CMD_NOPROMPT "noprompt"
|
||||
SHELL_REGISTER_COMMAND(SHELL_CMD_NOPROMPT, cmd_noprompt,
|
||||
"Disable shell prompt");
|
||||
|
||||
static const struct shell_cmd *get_internal(const char *command)
|
||||
{
|
||||
static const struct shell_cmd internal_commands[] = {
|
||||
|
@ -350,7 +361,6 @@ static const struct shell_cmd *get_internal(const char *command)
|
|||
return get_cmd(internal_commands, command);
|
||||
}
|
||||
|
||||
|
||||
int shell_exec(char *line)
|
||||
{
|
||||
char *argv[ARGC_MAX + 1], **argv_start = argv;
|
||||
|
@ -424,11 +434,13 @@ static void shell(void *p1, void *p2, void *p3)
|
|||
while (1) {
|
||||
struct console_input *cmd;
|
||||
|
||||
printk("%s", get_prompt());
|
||||
if (!no_promt) {
|
||||
printk("%s", get_prompt());
|
||||
#if defined(CONFIG_NATIVE_POSIX_CONSOLE)
|
||||
/* The native printk driver is line buffered */
|
||||
posix_flush_stdout();
|
||||
/* The native printk driver is line buffered */
|
||||
posix_flush_stdout();
|
||||
#endif
|
||||
}
|
||||
|
||||
cmd = k_fifo_get(&cmds_queue, K_FOREVER);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue