Skip to content

Commit 3e65944

Browse files
Jakub RzeszutkoMaureenHelm
authored andcommitted
shell: documentation update
Updated the documantation with newly added configuration features. Added information where to find minimal shell config file. Added information how to activate particular features. Signed-off-by: Jakub Rzeszutko <[email protected]>
1 parent e2f8bfd commit 3e65944

File tree

3 files changed

+83
-35
lines changed

3 files changed

+83
-35
lines changed
25 KB
Loading

doc/reference/shell/index.rst

Lines changed: 82 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,22 @@ interaction is required. This module is a Unix-like shell with these features:
2121
* Smart command completion with the :kbd:`Tab` key.
2222
* Built-in commands: :command:`clear`, :command:`shell`, :command:`colors`,
2323
:command:`echo`, :command:`history` and :command:`resize`.
24-
* Viewing recently executed commands using keys: :kbd:`` :kbd:``.
24+
* Viewing recently executed commands using keys: :kbd:`` :kbd:`` or meta keys.
2525
* Text edition using keys: :kbd:``, :kbd:``, :kbd:`Backspace`,
2626
:kbd:`Delete`, :kbd:`End`, :kbd:`Home`, :kbd:`Insert`.
2727
* Support for ANSI escape codes: ``VT100`` and ``ESC[n~`` for cursor control
2828
and color printing.
29-
* Support for multiline commands.
29+
* Support for editing multiline commands.
3030
* Built-in handler to display help for the commands.
3131
* Support for wildcards: ``*`` and ``?``.
3232
* Support for meta keys.
3333
* Kconfig configuration to optimize memory usage.
3434

35+
Some of these features have a significant impact on RAM and flash usage,
36+
but many can be disabled when not needed. A configuration that should
37+
produce the minimum useful feature set is in
38+
:zephyr_file:`samples/subsys/shell/shell_module/prj_minimal.conf`.
39+
3540
The module can be connected to any transport for command input and output.
3641
At this point, the following transport layers are implemented:
3742

@@ -40,7 +45,7 @@ At this point, the following transport layers are implemented:
4045
* Telnet
4146
* UART
4247
* USB
43-
* DUMMY - not a physical transport layer
48+
* DUMMY - not a physical transport layer.
4449

4550
Connecting to Segger RTT via TCP (on macOS, for example)
4651
========================================================
@@ -355,6 +360,8 @@ commands or the parent commands, depending on how you index ``argv``.
355360
Built-in commands
356361
=================
357362

363+
These commands are activated by :option:`CONFIG_SHELL_CMDS` set to ``y``.
364+
358365
* :command:`clear` - Clears the screen.
359366
* :command:`history` - Shows the recently entered commands.
360367
* :command:`resize` - Must be executed when terminal width is different than 80
@@ -366,15 +373,50 @@ Built-in commands
366373
* :command:`default` - Shell will send terminal width = 80 to the
367374
terminal and assume successful delivery.
368375

376+
These command needs extra activation:
377+
:option:`CONFIG_SHELL_CMDS_RESIZE` set to ``y``.
378+
* :command:`select` - It can be used to set new root command. Exit to main
379+
command tree is with alt+r. This command needs extra activation:
380+
:option:`CONFIG_SHELL_CMDS_SELECT` set to ``y``.
369381
* :command:`shell` - Root command with useful shell-related subcommands like:
370382

371383
* :command:`echo` - Toggles shell echo.
372384
* :command:`colors` - Toggles colored syntax. This might be helpful in
373385
case of Bluetooth shell to limit the amount of transferred bytes.
374386
* :command:`stats` - Shows shell statistics.
375387

376-
Wildcards
377-
*********
388+
389+
Tab Feature
390+
***********
391+
392+
The Tab button can be used to suggest commands or subcommands. This feature
393+
is enabled by :option:`CONFIG_SHELL_TAB` set to ``y``.
394+
It can also be used for partial or complete auto-completion of commands.
395+
This feature is activated by
396+
:option:`CONFIG_SHELL_TAB_AUTOCOMPLETION` set to ``y``.
397+
When user starts writing a command and presses the :kbd:`Tab` button then
398+
the shell will do one of 3 possible things:
399+
400+
* Autocomplete the command.
401+
* Prompts available commands and if possible partly completes the command.
402+
* Will not do anything if there are no available or matching commands.
403+
404+
.. image:: images/tab_prompt.png
405+
:align: center
406+
:alt: Tab Feature usage example
407+
408+
History Feature
409+
***************
410+
411+
This feature enables commands history in the shell. It is activated by:
412+
:option:`CONFIG_SHELL_HISTORY` set to ``y``. History can be accessed
413+
using keys: :kbd:`` :kbd:`` or :kbd:`Ctrl + n` and :kbd:`Ctrl + p`
414+
if meta keys are active.
415+
Number of commands that can be stored depends on size
416+
of :option:`CONFIG_SHELL_HISTORY_BUFFER` parameter.
417+
418+
Wildcards Feature
419+
*****************
378420

379421
The shell module can handle wildcards. Wildcards are interpreted correctly
380422
when expanded command and its subcommands do not have a handler. For example,
@@ -389,8 +431,10 @@ modules you can execute the following command:
389431
:align: center
390432
:alt: Wildcard usage example
391433

392-
Meta keys
393-
*********
434+
This feature is activated by :option:`CONFIG_SHELL_WILDCARD` set to ``y``.
435+
436+
Meta Keys Feature
437+
*****************
394438

395439
The shell module supports the following meta keys:
396440

@@ -432,6 +476,37 @@ The shell module supports the following meta keys:
432476
* - :kbd:`Alt + f`
433477
- Moves the cursor forward one word.
434478

479+
This feature is activated by :option:`CONFIG_SHELL_METAKEYS` set to ``y``.
480+
481+
Shell Logger Backend Feature
482+
****************************
483+
484+
Shell instance can act as the :ref:`logging_api` backend. Shell ensures that log
485+
messages are correctly multiplexed with shell output. Log messages from logger
486+
thread are enqueued and processed in the shell thread. Logger thread will block
487+
for configurable amount of time if queue is full, blocking logger thread context
488+
for that time. Oldest log message is removed from the queue after timeout and
489+
new message is enqueued. Use the ``shell stats show`` command to retrieve
490+
number of log messages dropped by the shell instance. Log queue size and timeout
491+
are :c:macro:`SHELL_DEFINE` arguments.
492+
493+
This feature is activated by: :option:`CONFIG_SHELL_LOG_BACKEND` set to ``y``.
494+
495+
.. warning::
496+
Enqueuing timeout must be set carefully when multiple backends are used
497+
in the system. The shell instance could have a slow transport or could
498+
block, for example, by a UART with hardware flow control. If timeout is
499+
set too high, the logger thread could be blocked and impact other logger
500+
backends.
501+
502+
.. warning::
503+
As the shell is a complex logger backend, it can not output logs if
504+
the application crashes before the shell thread is running. In this
505+
situation, you can enable one of the simple logging backends instead,
506+
such as UART (:option:`CONFIG_LOG_BACKEND_UART`) or
507+
RTT (:option:`CONFIG_LOG_BACKEND_RTT`), which are available earlier
508+
during system initialization.
509+
435510
Usage
436511
*****
437512

@@ -515,33 +590,6 @@ the shell will only print the subcommands registered for this command:
515590
516591
params ping
517592
518-
Shell as the logger backend
519-
***************************
520-
521-
Shell instance can act as the :ref:`logging_api` backend. Shell ensures that log
522-
messages are correctly multiplexed with shell output. Log messages from logger
523-
thread are enqueued and processed in the shell thread. Logger thread will block
524-
for configurable amount of time if queue is full, blocking logger thread context
525-
for that time. Oldest log message is removed from the queue after timeout and
526-
new message is enqueued. Use the ``shell stats show`` command to retrieve
527-
number of log messages dropped by the shell instance. Log queue size and timeout
528-
are :c:macro:`SHELL_DEFINE` arguments.
529-
530-
.. warning::
531-
Enqueuing timeout must be set carefully when multiple backends are used
532-
in the system. The shell instance could have a slow transport or could
533-
block, for example, by a UART with hardware flow control. If timeout is
534-
set too high, the logger thread could be blocked and impact other logger
535-
backends.
536-
537-
.. warning::
538-
As the shell is a complex logger backend, it can not output logs if
539-
the application crashes before the shell thread is running. In this
540-
situation, you can enable one of the simple logging backends instead,
541-
such as UART (:option:`CONFIG_LOG_BACKEND_UART`) or
542-
RTT (:option:`CONFIG_LOG_BACKEND_RTT`), which are available earlier
543-
during system initialization.
544-
545593
API Reference
546594
*************
547595

subsys/shell/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ config SHELL_HISTORY
125125
select RING_BUFFER
126126
help
127127
Enable commands history. History can be accessed using up and down
128-
arrows.
128+
arrows or Ctrl+n and Ctrl+p meta keys.
129129

130130
config SHELL_HISTORY_BUFFER
131131
int "History buffer in bytes"

0 commit comments

Comments
 (0)