summaryrefslogtreecommitdiff
path: root/searx/engines/command.py
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2023-06-30 18:07:02 +0200
committerMarkus Heiser <markus.heiser@darmarIT.de>2023-07-01 22:45:19 +0200
commit5720844fcdc8601798e10544e2fd25ce4f2ad099 (patch)
treeaf611e4aef436253f4fda9504d06e05e2621114d /searx/engines/command.py
parent8e8d8dabe9b17c9db8db7432c6bc063d9ae980d1 (diff)
downloadsearxng-5720844fcdc8601798e10544e2fd25ce4f2ad099.tar.gz
searxng-5720844fcdc8601798e10544e2fd25ce4f2ad099.zip
[doc] rearranges Settings & Engines docs for better readability
We have built up detailed documentation of the *settings* and the *engines* over the past few years. However, this documentation was still spread over various chapters and was difficult to navigate in its entirety. This patch rearranges the Settings & Engines documentation for better readability. To review new ordered docs:: make docs.clean docs.live Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/engines/command.py')
-rw-r--r--searx/engines/command.py75
1 files changed, 73 insertions, 2 deletions
diff --git a/searx/engines/command.py b/searx/engines/command.py
index abd29e2a5..ffb87509a 100644
--- a/searx/engines/command.py
+++ b/searx/engines/command.py
@@ -1,6 +1,77 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-"""
- Command (offline)
+"""With *command engines* administrators can run engines to integrate arbitrary
+shell commands.
+
+.. attention::
+
+ When creating and enabling a ``command`` engine on a public instance, you
+ must be careful to avoid leaking private data.
+
+The easiest solution is to limit the access by setting ``tokens`` as described
+in section :ref:`private engines`. The engine base is flexible. Only your
+imagination can limit the power of this engine (and maybe security concerns).
+
+Configuration
+=============
+
+The following options are available:
+
+``command``:
+ A comma separated list of the elements of the command. A special token
+ ``{{QUERY}}`` tells where to put the search terms of the user. Example:
+
+ .. code:: yaml
+
+ ['ls', '-l', '-h', '{{QUERY}}']
+
+``delimiter``:
+ A mapping containing a delimiter ``char`` and the *titles* of each element in
+ ``keys``.
+
+``parse_regex``:
+ A dict containing the regular expressions for each result key.
+
+``query_type``:
+
+ The expected type of user search terms. Possible values: ``path`` and
+ ``enum``.
+
+ ``path``:
+ Checks if the user provided path is inside the working directory. If not,
+ the query is not executed.
+
+ ``enum``:
+ Is a list of allowed search terms. If the user submits something which is
+ not included in the list, the query returns an error.
+
+``query_enum``:
+ A list containing allowed search terms if ``query_type`` is set to ``enum``.
+
+``working_dir``:
+ The directory where the command has to be executed. Default: ``./``.
+
+``result_separator``:
+ The character that separates results. Default: ``\\n``.
+
+Example
+=======
+
+The example engine below can be used to find files with a specific name in the
+configured working directory:
+
+.. code:: yaml
+
+ - name: find
+ engine: command
+ command: ['find', '.', '-name', '{{QUERY}}']
+ query_type: path
+ shortcut: fnd
+ delimiter:
+ chars: ' '
+ keys: ['line']
+
+Implementations
+===============
"""
import re