Lines Matching full:command
13 This module allows you to create and handle a shell with a user-defined command
21 * Smart command completion with the :kbd:`Tab` key.
22 * Built-in commands: :command:`clear`, :command:`shell`, :command:`colors`,
23 :command:`echo`, :command:`history` and :command:`resize`.
48 The module can be connected to any transport for command input and output.
73 command support can be enabled with :kconfig:option:`CONFIG_SHELL_TELNET_SUPPORT_COMMAND`.
75 still can be turned on if needed. One of the command options it supports is the ``ECHO``
180 * Root command (level 0): Gathered and alphabetically sorted in a dedicated
188 Commonly-used command groups
191 The following list is a set of useful command groups and how to enable them:
228 * :c:macro:`SHELL_CMD_REGISTER` - Create root command. All root commands must
231 set) create root command. All root commands must have different name.
232 * :c:macro:`SHELL_CMD_ARG_REGISTER` - Create root command with arguments.
235 is set) create root command with arguments. All root commands must have
237 * :c:macro:`SHELL_CMD` - Initialize a command.
238 * :c:macro:`SHELL_COND_CMD` - Initialize a command if compile time flag is set.
239 * :c:macro:`SHELL_EXPR_CMD` - Initialize a command if compile time expression is
241 * :c:macro:`SHELL_CMD_ARG` - Initialize a command with arguments.
242 * :c:macro:`SHELL_COND_CMD_ARG` - Initialize a command with arguments if compile
244 * :c:macro:`SHELL_EXPR_CMD_ARG` - Initialize a command with arguments if compile
259 Example code demonstrating how to create a root command with static
264 :alt: Command tree with static commands.
268 /* Creating subcommands (level 1 command) array for command "demo". */
270 SHELL_CMD(params, NULL, "Print params command.",
272 SHELL_CMD(ping, NULL, "Ping command.", cmd_demo_ping),
275 /* Creating root (level 0) command "demo" */
285 a command handler. The string is usually a verbal description of a given data.
286 The idea is to use the string as a command syntax that can be prompted by the
287 shell and corresponding data can be used to process the command.
289 Let's use an example. Suppose you created a command to set an ADC gain.
303 /* data is a value corresponding to called command syntax */
331 Example code demonstrating how to create a root command with static and dynamic
332 subcommands. At the beginning dynamic command list is empty. New commands
343 :alt: Command tree with static and dynamic commands.
353 /* Function returning command dynamically created
363 entry->help = "Show dynamic command name.";
374 SHELL_CMD(add, NULL,"Add new command to dynamic_cmd_buffer and"
378 "Execute a command.", cmd_dynamic_execute),
380 "Remove a command from dynamic_cmd_buffer.",
388 "Demonstrate dynamic command usage.", cmd_dynamic);
396 Each command or subcommand may have a handler. The shell executes the handler
397 that is found deepest in the command tree and further subcommands (without a
408 /* Below code will execute "clear" command on a DUMMY backend */
411 /* Below code will execute "shell colors off" command on
424 Let's assume a command structure as in the following figure, where:
426 * :c:macro:`root_cmd` - root command without a handler
427 * :c:macro:`cmd_xxx_h` - command has a handler
428 * :c:macro:`cmd_xxx` - command does not have a handler
432 :alt: Command tree with static commands.
437 :c:macro:`cmd_121_h` :c:macro:`parameter` will execute command
443 :c:macro:`parameter1` :c:macro:`parameter2` will execute command
450 :c:macro:`cmd_121_h` :c:macro:`parameter2` will execute command
457 :c:macro:`parameter2` will not execute any command.
460 Command handler
463 Simple command handler implementation:
486 :c:macro:`shell_error` can be used from the command handler or from threads,
490 Command help
493 Every user-defined command or subcommand can have its own help description.
498 Shell prints this help message when you call a command
519 /* If it is a subcommand handler parent command syntax
522 shell_print(sh, "This command has a parent command: %s",
525 /* Print this command syntax */
526 shell_print(sh, "This command syntax is: %s", argv[0]);
539 * :command:`clear` - Clears the screen.
540 * :command:`history` - Shows the recently entered commands.
541 * :command:`resize` - Must be executed when terminal width is different than 80
544 handling. Currently this command works only with UART flow control switched
547 * :command:`default` - Shell will send terminal width = 80 to the
550 These command needs extra activation:
552 * :command:`select` - It can be used to set new root command. Exit to main
553 command tree is with alt+r. This command needs extra activation:
555 * :command:`shell` - Root command with useful shell-related subcommands like:
557 * :command:`echo` - Toggles shell echo.
558 * :command:`colors` - Toggles colored syntax. This might be helpful in
560 * :command:`stats` - Shows shell statistics.
572 When user starts writing a command and presses the :kbd:`Tab` button then
575 * Autocomplete the command.
576 * Prompts available commands and if possible partly completes the command.
599 when expanded command and its subcommands do not have a handler. For example,
601 modules you can execute the following command:
629 - Preserves the last command on the screen and starts a new command in
640 - Clears the screen and leaves the currently typed command at the top of
647 - Clears the currently typed command.
727 of any other command besides a login command, by means of the
740 new message is enqueued. Use the ``shell stats show`` command to retrieve
818 /* Creating subcommands (level 1 command) array for command "demo". */
820 SHELL_CMD(params, NULL, "Print params command.",
822 SHELL_CMD(ping, NULL, "Ping command.", cmd_demo_ping),
825 /* Creating root (level 0) command "demo" without a handler */
828 /* Creating root (level 0) command "version" */
832 Users may use the :kbd:`Tab` key to complete a command/subcommand or to see the
833 available subcommands for the currently entered command level.
834 For example, when the cursor is positioned at the beginning of the command
844 To view the subcommands that are available for a specific command, you
845 must first type a :kbd:`space` after this command and then hit
850 * :command:`clear`, :command:`shell`, :command:`history`, and :command:`resize`
853 * :command:`demo` and :command:`version` have been registered in example code
855 * :command:`log` has been registered by :zephyr_file:`subsys/logging/log_cmds.c`
857 Then, if a user types a :command:`demo` command and presses the :kbd:`Tab` key,
858 the shell will only print the subcommands registered for this command: