Skip to content

Commit 45d5fb7

Browse files
Jakub Rzeszutkocarlescufi
authored andcommitted
shell: doc: adding information on command execution
Supplemental information on shell command execution. Added an illustration and four examples showing how the shell will call the handler and what it will pass as an argument. Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
1 parent 68cc29d commit 45d5fb7

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
33.4 KB
Loading

doc/services/shell/index.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,44 @@ and a function :c:func:`shell_execute_cmd`, as shown in this example:
285285
Enable the DUMMY backend by setting the Kconfig
286286
:kconfig:option:`CONFIG_SHELL_BACKEND_DUMMY` option.
287287

288+
Commands execution example
289+
--------------------------
290+
291+
Let's assume a command structure as in the following figure, where:
292+
293+
* :c:macro:`root_cmd` - root command without a handler
294+
* :c:macro:`cmd_xxx_h` - command has a handler
295+
* :c:macro:`cmd_xxx` - command does not have a handler
296+
297+
.. image:: images/static_cmd.PNG
298+
:align: center
299+
:alt: Command tree with static commands.
300+
301+
Example 1
302+
^^^^^^^^^
303+
Sequence: :c:macro:`root_cmd` :c:macro:`cmd_1_h` :c:macro:`cmd_12_h`
304+
:c:macro:`cmd_121_h` :c:macro:`parameter` will execute command
305+
:c:macro:`cmd_121_h` and :c:macro:`parameter` will be passed as an argument.
306+
307+
Example 2
308+
^^^^^^^^^
309+
Sequence: :c:macro:`root_cmd` :c:macro:`cmd_2` :c:macro:`cmd_22_h`
310+
:c:macro:`parameter1` :c:macro:`parameter2` will execute command
311+
:c:macro:`cmd_22_h` and :c:macro:`parameter1` :c:macro:`parameter2`
312+
will be passed as an arguments.
313+
314+
Example 3
315+
^^^^^^^^^
316+
Sequence: :c:macro:`root_cmd` :c:macro:`cmd_1_h` :c:macro:`parameter1`
317+
:c:macro:`cmd_121_h` :c:macro:`parameter2` will execute command
318+
:c:macro:`cmd_1_h` and :c:macro:`parameter1`, :c:macro:`cmd_121_h` and
319+
:c:macro:`parameter2` will be passed as an arguments.
320+
321+
Example 4
322+
^^^^^^^^^
323+
Sequence: :c:macro:`root_cmd` :c:macro:`parameter` :c:macro:`cmd_121_h`
324+
:c:macro:`parameter2` will not execute any command.
325+
288326

289327
Command handler
290328
----------------

0 commit comments

Comments
 (0)