Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for CLI command completions #693

Merged
merged 15 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Improve documentation on shell completions
  • Loading branch information
juhoinkinen committed Apr 25, 2023
commit 35bc222e5a65d3594d2252830c95876259d00059
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,25 @@ in the wiki for more details.
Annif supports tab-key completion in bash, zsh and fish shells for commands and options
and project id, vocabulary id and path parameters.

To enable completion support in your current terminal session use `annif completion`
To enable the completion support in your current terminal session use `annif completion`
command with the option according to your shell to produce the completion script and
source it. For example, run

source <(annif completion --bash)

To enable completion support in all new sessions first add the completion script in your
home directory:
To enable the completion support in all new sessions first add the completion script in
your home directory:

annif completion --bash > ~/.annif-complete.bash

Then make the script to be automatically sourced for new terminal sessions by adding the
following to your `~/.bashrc` file (or in [alternative startup
files](https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html)):
following to your `~/.bashrc` file (or in some [alternative startup
file](https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html)):

source ~/.annif-complete.bash

You can also add just the completion script in your `/etc/bash_completion.d/`
directory.

For details and usage for other shells see
[Click documentation](https://click.palletsprojects.com/en/8.1.x/shell-completion/).
# Docker install

You can use Annif as a pre-built Docker container. Please see the
Expand Down
5 changes: 4 additions & 1 deletion annif/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,10 @@ def run_hyperopt(project_id, paths, docs_limit, trials, jobs, metric, results_fi
@click.option("--zsh", "shell", flag_value="zsh")
@click.option("--fish", "shell", flag_value="fish")
def completion(shell):
"""Generate autocompletion script for the given shell."""
"""Generate the script for tab-key autocompletion for the given shell. To enable the
completion support in your current bash terminal session run\n
source <(annif completion --bash)
"""

if shell is None:
raise click.UsageError("Shell not given, try --bash, --zsh or --fish")
Expand Down
Loading