From 0e33cf5ee3c5b0df250a7c069bc17ac68e4115fc Mon Sep 17 00:00:00 2001 From: Sebastiaan Huber Date: Tue, 31 Aug 2021 18:47:57 +0200 Subject: [PATCH] Dependencies: remove `click-completion` As of `click==8.0` the full set of functionality that `click-completion` provided for our tab-completion is now shipped with `click` itself, so we can remove this dependency. The main difference is that the string that is required to activate it, is slightly different and it is shell dependent. The documentation has been updated to correctly reflect this. Since it is now shell dependent, the old `verdi completioncommand`, which was already (unofficially) deprecated is no longer correct. To keep it correct, one would have to try and detect the shell but this is clearly outside of the scope of `aiida-core` so we simply remote it. --- aiida/cmdline/commands/__init__.py | 11 ++------ .../cmdline/commands/cmd_completioncommand.py | 28 ------------------- docs/source/howto/installation.rst | 27 ++++++++++++++++-- docs/source/nitpick-exceptions | 1 + docs/source/reference/command_line.rst | 18 ------------ environment.yml | 1 - setup.json | 1 - 7 files changed, 28 insertions(+), 59 deletions(-) delete mode 100644 aiida/cmdline/commands/cmd_completioncommand.py diff --git a/aiida/cmdline/commands/__init__.py b/aiida/cmdline/commands/__init__.py index 3e88c5b752..badf6f3e3b 100644 --- a/aiida/cmdline/commands/__init__.py +++ b/aiida/cmdline/commands/__init__.py @@ -7,19 +7,14 @@ # For further information on the license, see the LICENSE.txt file # # For further information please visit http://www.aiida.net # ########################################################################### -# pylint: disable=too-many-arguments,wrong-import-position -"""The `verdi` command line interface.""" -import click_completion +"""Sub commands of the ``verdi`` command line interface. -# Activate the completion of parameter types provided by the click_completion package -click_completion.init() - -# Import to populate the `verdi` sub commands +The commands need to be imported here for them to be registered with the top-level command group. +""" from aiida.cmdline.commands import ( cmd_archive, cmd_calcjob, cmd_code, - cmd_completioncommand, cmd_computer, cmd_config, cmd_daemon, diff --git a/aiida/cmdline/commands/cmd_completioncommand.py b/aiida/cmdline/commands/cmd_completioncommand.py deleted file mode 100644 index 7e319dd84e..0000000000 --- a/aiida/cmdline/commands/cmd_completioncommand.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- -########################################################################### -# Copyright (c), The AiiDA team. All rights reserved. # -# This file is part of the AiiDA code. # -# # -# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core # -# For further information on the license, see the LICENSE.txt file # -# For further information please visit http://www.aiida.net # -########################################################################### -""" -`verdi completioncommand` command, to return the string to insert -into the bash script to activate completion. -""" -import click - -from aiida.cmdline.commands.cmd_verdi import verdi - - -@verdi.command('completioncommand') -def verdi_completioncommand(): - """Return the code to activate bash completion. - - \b - This command is mainly for back-compatibility. - You should rather use: eval "$(_VERDI_COMPLETE=source verdi)" - """ - from click_completion import get_auto_shell, get_code - click.echo(get_code(shell=get_auto_shell())) diff --git a/docs/source/howto/installation.rst b/docs/source/howto/installation.rst index 459f092c3e..b059e6adef 100644 --- a/docs/source/howto/installation.rst +++ b/docs/source/howto/installation.rst @@ -79,11 +79,32 @@ Configuring your installation Activating tab-completion ------------------------- The ``verdi`` command line interface has many commands and parameters, which can be tab-completed to simplify its use. -To enable tab-completion, the following shell command should be executed: +To enable tab-completion, the following shell command should be executed (depending on the shell you use): -.. code:: bash +.. panels:: + :container: container-lg pb-3 + :column: col-lg-12 p-2 + + Enable tab-completion for ``verdi`` one of the following supported shells + + .. tabbed:: bash + + .. code-block:: console + + eval "$(_VERDI_COMPLETE=bash_source verdi)" + + .. tabbed:: zsh + + .. code-block:: console + + eval "$(_VERDI_COMPLETE=zsh_source verdi)" + + .. tabbed:: fish + + .. code-block:: console + + eval (env _FOO_BAR_COMPLETE=fish_source foo-bar) - $ eval "$(_VERDI_COMPLETE=source verdi)" Place this command in your shell or virtual environment activation script to automatically enable tab completion when opening a new shell or activating an environment. This file is shell specific, but likely one of the following: diff --git a/docs/source/nitpick-exceptions b/docs/source/nitpick-exceptions index bb2f466230..87346157c9 100644 --- a/docs/source/nitpick-exceptions +++ b/docs/source/nitpick-exceptions @@ -120,6 +120,7 @@ py:class click.types.StringParamType py:class click.types.Path py:class click.types.File py:meth click.Option.get_default +py:meth fail py:class concurrent.futures._base.TimeoutError diff --git a/docs/source/reference/command_line.rst b/docs/source/reference/command_line.rst index 249387e732..45f53f41e4 100644 --- a/docs/source/reference/command_line.rst +++ b/docs/source/reference/command_line.rst @@ -80,24 +80,6 @@ Below is a list with all available subcommands. show Display detailed information for a code. -.. _reference:command-line:verdi-completioncommand: - -``verdi completioncommand`` ---------------------------- - -.. code:: console - - Usage: [OPTIONS] - - Return the code to activate bash completion. - - This command is mainly for back-compatibility. - You should rather use: eval "$(_VERDI_COMPLETE=source verdi)" - - Options: - --help Show this message and exit. - - .. _reference:command-line:verdi-computer: ``verdi computer`` diff --git a/environment.yml b/environment.yml index 728b311167..1bf191883f 100644 --- a/environment.yml +++ b/environment.yml @@ -11,7 +11,6 @@ dependencies: - archive-path~=0.2.1 - aio-pika~=6.6 - circus~=0.17.1 -- click-completion~=0.5.1 - click-config-file~=0.6.0 - click-spinner~=0.1.8 - click>=8.0.3,~=8.0 diff --git a/setup.json b/setup.json index 30c78e1566..fbcc7d5b69 100644 --- a/setup.json +++ b/setup.json @@ -25,7 +25,6 @@ "archive-path~=0.2.1", "aio-pika~=6.6", "circus~=0.17.1", - "click-completion~=0.5.1", "click-config-file~=0.6.0", "click-spinner~=0.1.8", "click~=8.0,>=8.0.3",