2016-07-31 21:16:29 +08:00
|
|
|
.. _shell:
|
|
|
|
|
2016-12-18 01:54:02 +08:00
|
|
|
Shell
|
|
|
|
######
|
2016-07-31 21:16:29 +08:00
|
|
|
|
|
|
|
Overview
|
|
|
|
********
|
|
|
|
|
2016-12-24 03:06:46 +08:00
|
|
|
The Shell enables multiple subsystem to use and expose their shell interface
|
|
|
|
simultaneously.
|
2016-07-31 21:16:29 +08:00
|
|
|
|
2017-02-28 05:15:43 +08:00
|
|
|
Each subsystem can support shell functionality dynamically by its Kconfig file,
|
2016-12-24 03:06:46 +08:00
|
|
|
which enables or disables the shell usage for the subsystem.
|
2016-07-31 21:16:29 +08:00
|
|
|
|
|
|
|
Using shell commands
|
|
|
|
********************
|
|
|
|
|
|
|
|
Use one of the following formats:
|
|
|
|
|
|
|
|
Specific module's commands
|
|
|
|
==========================
|
2016-12-24 03:06:46 +08:00
|
|
|
|
|
|
|
A shell interface exposing subsystem features is a shell module, multiple
|
|
|
|
modules can be available at the same time.
|
|
|
|
|
doc: fix uses of back quotes in documentation
ReST defines interpreted text roles where text enclosed by single quotes
can be "intrepreted", for example :ref:`some name` becomes a link to
a label anywhere in the doc set named "some name", :c:func:`funcname()`
becomes a link to the API documentation for "funcname", and
:option:`CONFIG_NAME` becomes a link to, in our case, the documentation
for the generated Kconfig option.
This patch fixes uses of `some name` (without a role) by either adding
an explicit role, or changing to ``some name``, which indicates inline
code block formatting (most likely what was intended).
This is a precursor to changing the default behavior of interpreted
text to treat `some name` as :any:`some name` (as configured in
doc/conf.py), which would attempt to create a link to any available
definition of "some name".
We may not change this default role behavior, but it becomes an option
after the fixes in this patch. In any case, this patch fixes incorrect
uses of single-quoted text (possibly introduced because GitHub's
markdown language uses single-quoted text for inline code formatting).
Jira: ZEP-2414
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-08-02 06:20:20 +08:00
|
|
|
``MODULE_NAME COMMAND``
|
2017-05-10 06:38:30 +08:00
|
|
|
One of the available modules is "KERNEL", for the Kernel module. More
|
2016-12-24 02:25:47 +08:00
|
|
|
information can be found in :c:macro:`SHELL_REGISTER`.
|
2016-07-31 21:16:29 +08:00
|
|
|
|
|
|
|
Help commands
|
|
|
|
=============
|
2016-12-24 03:06:46 +08:00
|
|
|
|
doc: fix uses of back quotes in documentation
ReST defines interpreted text roles where text enclosed by single quotes
can be "intrepreted", for example :ref:`some name` becomes a link to
a label anywhere in the doc set named "some name", :c:func:`funcname()`
becomes a link to the API documentation for "funcname", and
:option:`CONFIG_NAME` becomes a link to, in our case, the documentation
for the generated Kconfig option.
This patch fixes uses of `some name` (without a role) by either adding
an explicit role, or changing to ``some name``, which indicates inline
code block formatting (most likely what was intended).
This is a precursor to changing the default behavior of interpreted
text to treat `some name` as :any:`some name` (as configured in
doc/conf.py), which would attempt to create a link to any available
definition of "some name".
We may not change this default role behavior, but it becomes an option
after the fixes in this patch. In any case, this patch fixes incorrect
uses of single-quoted text (possibly introduced because GitHub's
markdown language uses single-quoted text for inline code formatting).
Jira: ZEP-2414
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-08-02 06:20:20 +08:00
|
|
|
``help``
|
2016-12-24 03:06:46 +08:00
|
|
|
Prints the list of available modules.
|
2016-12-24 02:25:47 +08:00
|
|
|
|
doc: fix uses of back quotes in documentation
ReST defines interpreted text roles where text enclosed by single quotes
can be "intrepreted", for example :ref:`some name` becomes a link to
a label anywhere in the doc set named "some name", :c:func:`funcname()`
becomes a link to the API documentation for "funcname", and
:option:`CONFIG_NAME` becomes a link to, in our case, the documentation
for the generated Kconfig option.
This patch fixes uses of `some name` (without a role) by either adding
an explicit role, or changing to ``some name``, which indicates inline
code block formatting (most likely what was intended).
This is a precursor to changing the default behavior of interpreted
text to treat `some name` as :any:`some name` (as configured in
doc/conf.py), which would attempt to create a link to any available
definition of "some name".
We may not change this default role behavior, but it becomes an option
after the fixes in this patch. In any case, this patch fixes incorrect
uses of single-quoted text (possibly introduced because GitHub's
markdown language uses single-quoted text for inline code formatting).
Jira: ZEP-2414
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-08-02 06:20:20 +08:00
|
|
|
``help MODULE_NAME``
|
2016-12-24 02:25:47 +08:00
|
|
|
Prints the names of the available commands for the module.
|
|
|
|
|
doc: fix uses of back quotes in documentation
ReST defines interpreted text roles where text enclosed by single quotes
can be "intrepreted", for example :ref:`some name` becomes a link to
a label anywhere in the doc set named "some name", :c:func:`funcname()`
becomes a link to the API documentation for "funcname", and
:option:`CONFIG_NAME` becomes a link to, in our case, the documentation
for the generated Kconfig option.
This patch fixes uses of `some name` (without a role) by either adding
an explicit role, or changing to ``some name``, which indicates inline
code block formatting (most likely what was intended).
This is a precursor to changing the default behavior of interpreted
text to treat `some name` as :any:`some name` (as configured in
doc/conf.py), which would attempt to create a link to any available
definition of "some name".
We may not change this default role behavior, but it becomes an option
after the fixes in this patch. In any case, this patch fixes incorrect
uses of single-quoted text (possibly introduced because GitHub's
markdown language uses single-quoted text for inline code formatting).
Jira: ZEP-2414
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-08-02 06:20:20 +08:00
|
|
|
``help MODULE_NAME COMMAND``
|
2016-12-24 02:25:47 +08:00
|
|
|
Prints help for the module's command (the help should show function
|
|
|
|
goal and required parameters).
|
2016-07-31 21:16:29 +08:00
|
|
|
|
|
|
|
Select module commands
|
|
|
|
======================
|
2016-12-24 03:06:46 +08:00
|
|
|
|
doc: fix uses of back quotes in documentation
ReST defines interpreted text roles where text enclosed by single quotes
can be "intrepreted", for example :ref:`some name` becomes a link to
a label anywhere in the doc set named "some name", :c:func:`funcname()`
becomes a link to the API documentation for "funcname", and
:option:`CONFIG_NAME` becomes a link to, in our case, the documentation
for the generated Kconfig option.
This patch fixes uses of `some name` (without a role) by either adding
an explicit role, or changing to ``some name``, which indicates inline
code block formatting (most likely what was intended).
This is a precursor to changing the default behavior of interpreted
text to treat `some name` as :any:`some name` (as configured in
doc/conf.py), which would attempt to create a link to any available
definition of "some name".
We may not change this default role behavior, but it becomes an option
after the fixes in this patch. In any case, this patch fixes incorrect
uses of single-quoted text (possibly introduced because GitHub's
markdown language uses single-quoted text for inline code formatting).
Jira: ZEP-2414
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-08-02 06:20:20 +08:00
|
|
|
``select MODULE_NAME``
|
2016-12-24 02:25:47 +08:00
|
|
|
Use this command when using the shell only for one module. After entering this
|
|
|
|
command, you will not need to enter module name in further commands. If
|
|
|
|
the selected module has set a default shell prompt during its initialization,
|
|
|
|
the prompt will be changed to that one. Otherwise, the prompt will be
|
2017-05-10 06:38:30 +08:00
|
|
|
changed to the selected module's name to reflect the current module in use.
|
2016-12-24 02:25:47 +08:00
|
|
|
|
doc: fix uses of back quotes in documentation
ReST defines interpreted text roles where text enclosed by single quotes
can be "intrepreted", for example :ref:`some name` becomes a link to
a label anywhere in the doc set named "some name", :c:func:`funcname()`
becomes a link to the API documentation for "funcname", and
:option:`CONFIG_NAME` becomes a link to, in our case, the documentation
for the generated Kconfig option.
This patch fixes uses of `some name` (without a role) by either adding
an explicit role, or changing to ``some name``, which indicates inline
code block formatting (most likely what was intended).
This is a precursor to changing the default behavior of interpreted
text to treat `some name` as :any:`some name` (as configured in
doc/conf.py), which would attempt to create a link to any available
definition of "some name".
We may not change this default role behavior, but it becomes an option
after the fixes in this patch. In any case, this patch fixes incorrect
uses of single-quoted text (possibly introduced because GitHub's
markdown language uses single-quoted text for inline code formatting).
Jira: ZEP-2414
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-08-02 06:20:20 +08:00
|
|
|
``select``
|
2016-12-24 02:25:47 +08:00
|
|
|
Clears selected module. Restores prompt as well.
|
2016-07-31 21:16:29 +08:00
|
|
|
|
|
|
|
Shell configuration
|
|
|
|
*******************
|
|
|
|
There are two levels of configuration: Infrastructure level and Module level.
|
|
|
|
|
|
|
|
Infrastructure level
|
|
|
|
====================
|
2016-12-24 02:25:47 +08:00
|
|
|
|
2016-12-24 03:06:46 +08:00
|
|
|
The option :option:`CONFIG_CONSOLE_SHELL` enables the shell subsystem and enable the
|
|
|
|
default features of the shell subsystem.
|
2016-12-24 02:25:47 +08:00
|
|
|
|
2016-12-24 03:06:46 +08:00
|
|
|
Module/Subsystem level
|
|
|
|
======================
|
|
|
|
Each subsystem using the shell service should add a unique flag in its Kconfig file.
|
2016-07-31 21:16:29 +08:00
|
|
|
|
|
|
|
Example:
|
2016-12-24 02:25:47 +08:00
|
|
|
|
2016-12-24 03:06:46 +08:00
|
|
|
CONFIG_NET_SHELL=y
|
2016-07-31 21:16:29 +08:00
|
|
|
|
2017-05-10 06:38:30 +08:00
|
|
|
In the subsystem's code, the shell usage depends on this config parameter.
|
2016-12-24 03:06:46 +08:00
|
|
|
This subsystem specific flag should also depend on :option:`CONFIG_CONSOLE_SHELL` flag.
|
2016-07-31 21:16:29 +08:00
|
|
|
|
|
|
|
Configuration steps to add shell functionality to a module
|
|
|
|
==========================================================
|
2016-12-24 02:25:47 +08:00
|
|
|
|
2016-12-24 03:06:46 +08:00
|
|
|
#. Check that :option:`CONFIG_CONSOLE_SHELL` is set to yes.
|
|
|
|
#. Add the subsystem unique flag to its Kconfig file.
|
2016-07-31 21:16:29 +08:00
|
|
|
|
|
|
|
Writing a shell module
|
|
|
|
**********************
|
2016-12-24 02:25:47 +08:00
|
|
|
|
2016-12-24 03:06:46 +08:00
|
|
|
In order to support shell in your subsystem, the application must do the following:
|
2016-07-31 21:16:29 +08:00
|
|
|
|
2016-12-24 03:06:46 +08:00
|
|
|
#. Module configuration flag: Declare a new flag in your subsystem Kconfig file.
|
2017-04-27 02:15:25 +08:00
|
|
|
It should depend on :option:`CONFIG_CONSOLE_SHELL` flag.
|
2016-12-24 02:25:47 +08:00
|
|
|
|
|
|
|
#. Module registration to shell: Add your shell identifier and register its
|
|
|
|
callback functions in the shell database using :c:macro:`SHELL_REGISTER`.
|
|
|
|
|
|
|
|
Optionally, you can use one of the following API functions to override default
|
2017-02-28 05:15:43 +08:00
|
|
|
behavior and settings:
|
2016-07-31 21:16:29 +08:00
|
|
|
|
2016-12-24 02:25:47 +08:00
|
|
|
* :c:func:`shell_register_default_module`
|
2016-07-31 21:16:29 +08:00
|
|
|
|
2016-12-24 02:25:47 +08:00
|
|
|
* :c:func:`shell_register_prompt_handler`
|
2016-07-31 21:16:29 +08:00
|
|
|
|
2016-12-24 02:25:47 +08:00
|
|
|
In case of a sample applications as well as test environment, user can choose to
|
|
|
|
set a default module in code level. In this case, the function
|
|
|
|
shell_register_default_module should be called after calling SHELL_REGISTER in
|
|
|
|
application level. If the function shell_register_prompt_handler was called as
|
|
|
|
well, the prompt will be changed to that one. Otherwise, the prompt will be
|
2017-05-10 06:38:30 +08:00
|
|
|
changed to the selected module's name, in order to reflect the current module in
|
2016-12-24 02:25:47 +08:00
|
|
|
use.
|
2016-07-31 21:16:29 +08:00
|
|
|
|
|
|
|
|
2016-12-24 02:25:47 +08:00
|
|
|
.. note::
|
2017-01-09 02:23:49 +08:00
|
|
|
|
|
|
|
Even if a default module was set in code level, it can be overwritten by
|
|
|
|
"select" shell command.
|
2016-07-31 21:16:29 +08:00
|
|
|
|
2016-12-24 02:25:47 +08:00
|
|
|
You can use :c:func:`shell_register_default_module` in the following cases:
|
2016-07-31 21:16:29 +08:00
|
|
|
|
2016-12-24 02:25:47 +08:00
|
|
|
* Use this command in case of using the shell only for one module.
|
|
|
|
After entering this command, no need to enter module name in further
|
|
|
|
commands.
|
2016-07-31 21:16:29 +08:00
|
|
|
|
2016-12-24 02:25:47 +08:00
|
|
|
* Use this function for shell backward compatibility.
|
2016-07-31 21:16:29 +08:00
|
|
|
|
2016-12-24 02:25:47 +08:00
|
|
|
More details on those optional functions can be found in
|
|
|
|
:ref:`shell_api_functions`.
|
2016-07-31 21:16:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
.. _shell_api_functions:
|
|
|
|
|
2017-01-09 02:23:49 +08:00
|
|
|
Shell API Functions
|
2016-07-31 21:16:29 +08:00
|
|
|
*******************
|
|
|
|
.. doxygengroup:: _shell_api_functions
|
|
|
|
:project: Zephyr
|
|
|
|
:content-only:
|