Skip to content

Commit 6675f47

Browse files
Jakub Rzeszutkonashif
authored andcommitted
doc: shell update with getopt
Update of the shell documentation with getopt feature. Signed-off-by: Jakub Rzeszutko <[email protected]>
1 parent 99d064e commit 6675f47

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

doc/reference/shell/index.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ interaction is required. This module is a Unix-like shell with these features:
3030
* Built-in handler to display help for the commands.
3131
* Support for wildcards: ``*`` and ``?``.
3232
* Support for meta keys.
33+
* Support for getopt.
3334
* Kconfig configuration to optimize memory usage.
3435

3536
.. note::
@@ -480,6 +481,28 @@ The shell module supports the following meta keys:
480481

481482
This feature is activated by :option:`CONFIG_SHELL_METAKEYS` set to ``y``.
482483

484+
Getopt Feature
485+
*****************
486+
487+
Some shell users apart from subcommands might need to use options as well.
488+
the arguments string, looking for supported options. Typically, this task
489+
is accomplished by the ``getopt`` function.
490+
491+
For this purpose shell supports the getopt library available
492+
in the FreeBSD project. I was modified so that it can be used
493+
by all instances of the shell at the same time, hence its call requires
494+
one more parameter.
495+
496+
An example usage:
497+
498+
.. code-block:: c
499+
500+
while ((char c = shell_getopt(shell, argc, argv, "abhc:")) != -1) {
501+
/* some code */
502+
}
503+
504+
This module is activated by :option:`CONFIG_SHELL_GETOPT` set to ``y``.
505+
483506
Shell Logger Backend Feature
484507
****************************
485508

0 commit comments

Comments
 (0)