diff --git a/aiomonitor/termui/commands.py b/aiomonitor/termui/commands.py index 7c65b9e..eeb0e64 100644 --- a/aiomonitor/termui/commands.py +++ b/aiomonitor/termui/commands.py @@ -38,6 +38,9 @@ __all__ = ( "interact", "monitor_cli", + "auto_command_done", + "auto_async_command_done", + "custom_help_option", ) diff --git a/docs/conf.py b/docs/conf.py index 641241a..34c240b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -52,6 +52,7 @@ "sphinx.ext.coverage", "sphinx.ext.viewcode", "sphinx_autodoc_typehints", + "sphinx_click", ] # Add any paths that contain templates here, relative to this directory. diff --git a/docs/index.rst b/docs/index.rst index f459b50..ff427ee 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -7,7 +7,7 @@ aiomonitor's documentation! =========================== **aiomonitor** is Python 3.8+ module that adds monitor and cli capabilities -for asyncio_ application. Idea and code borrowed from curio_ project. +for :mod:`asyncio` application. Idea and code borrowed from curio_ project. Task monitor that runs concurrently to the :mod:`asyncio` loop (or fast drop in replacement uvloop_) in a separate thread. This can inspect the loop and provide debugging capabilities. diff --git a/docs/reference/termui.rst b/docs/reference/termui.rst index e62da0c..1a513f3 100644 --- a/docs/reference/termui.rst +++ b/docs/reference/termui.rst @@ -11,6 +11,8 @@ Terminal UI .. seealso:: Check out the tutorial :ref:`cust-commands` about adding custom commands. +.. _monitor-cli: + ``aiomonitor.termui.commands`` ------------------------------ @@ -18,6 +20,9 @@ Terminal UI :members: :undoc-members: +.. click:: aiomonitor.termui.commands:monitor_cli + :prog: monitor_cli + ``aiomonitor.termui.completion`` -------------------------------- diff --git a/docs/tutorial.rst b/docs/tutorial.rst index b3e03a1..190790e 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -78,7 +78,7 @@ Once connection established, one can type commands, for instance ``help``:: where (w) Show stack frames and the task creation chain of a task where-terminated (wt) Show stack frames and the termination/cancellation chain of a task -Additional commands can be added by defining a Click command function injected into :func:`aiomonitor.termui.commands.monitor_cli`, see below :ref:`cust-commands`. +Additional commands can be added by defining a Click command function injected into :ref:`the monitor CLI `, see below :ref:`cust-commands`. .. versionchanged:: 0.5.0 @@ -150,12 +150,22 @@ As result variable ``foo`` available in console:: Adding custom commands ---------------------- -By defining a new :func:`Click command ` on ``monitor_cli``, we can add our own commands to the +By defining a new :func:`Click command ` on :ref:`the monitor CLI `, we can add our own commands to the telnet REPL. Use the standard :func:`click.echo()` to print something in the telnet console. You may also add additional arguments and options just like a normal Click application. .. code:: python + import aiohttp + import click + import requests + from aiomonitor.termui.commands import ( + auto_async_command_done, + auto_command_done, + custom_help_option, + monitor_cli, + ) + @monitor_cli.command(name="hello") @click.argument("name", optional=True) @custom_help_option