From 41fa7de95ff0a7f5e613962af568b3e9f618d5c4 Mon Sep 17 00:00:00 2001 From: Adam Birds Date: Sat, 1 May 2021 04:11:47 +0100 Subject: [PATCH] cli: Add support for bash-completion for `xkcd-pass`. Fixes #10. --- .github/workflows/build.yml | 2 -- .github/workflows/codecov.yml | 2 -- .github/workflows/publish-to-pypi.yml | 2 -- README.md | 13 +++++++++++++ requirements/dev.txt => requirements.txt | 2 ++ setup.py | 2 ++ src/xkcd_pass/xkcd_pass.py | 3 +++ 7 files changed, 20 insertions(+), 6 deletions(-) rename requirements/dev.txt => requirements.txt (93%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 263d921..fa6d991 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,8 +22,6 @@ jobs: sudo tools/setup/install-shfmt - name: Install Python dependencies uses: py-actions/py-dependency-install@v2 - with: - path: "requirements/dev.txt" - name: Run unittests run: | PYTHONPATH=src pytest diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 57bff82..8a38856 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -26,8 +26,6 @@ jobs: sudo tools/setup/install-shfmt - name: Install Python dependencies uses: py-actions/py-dependency-install@v2 - with: - path: "requirements/dev.txt" - name: Generate coverage report run: | PYTHONPATH=src pytest --cov=./ --cov-report=xml diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 88772c2..b44514e 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -23,8 +23,6 @@ jobs: sudo tools/setup/install-shfmt - name: Install Python dependencies uses: py-actions/py-dependency-install@v2 - with: - path: "requirements/dev.txt" - name: Run unittests run: | PYTHONPATH=src pytest diff --git a/README.md b/README.md index 0c3e323..bd4527b 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,19 @@ A full overview of the available options can be accessed by running following co xkcd-pass --help ``` +## Bash-Completion +`xkcd-pass` also supports bash-completion. To set this up you need to add the below to your `.bashrc` file: + +``` +eval "$(register-python-argcomplete xkcd-pass)" +``` + +This will then take effect the next time you login. To enable bash-completion immediately, you can run: + +``` +source .bashrc +``` + ## Word Lists Several word lists are provided with the package. The default, eff-long, was specifically designed by the EFF for [passphrase generation](https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases) and is licensed under [CC BY 3.0](https://creativecommons.org/licenses/by/3.0/us/). As it was originally intended for use with Diceware ensure that the number of words in your passphrase is at least six when using it. Two shorter variants of that list, eff-short and eff-special, are also included. Please refer to the EFF documentation linked above for more information. diff --git a/requirements/dev.txt b/requirements.txt similarity index 93% rename from requirements/dev.txt rename to requirements.txt index 19430fd..7183943 100644 --- a/requirements/dev.txt +++ b/requirements.txt @@ -1,3 +1,5 @@ +argcomplete + build https://github.com/zulip/zulint/archive/6cc46d23906757895e917cc75e231f81f824a31d.zip#egg=zulint==0.0.1 pytest diff --git a/setup.py b/setup.py index 3b332f0..3f0e317 100644 --- a/setup.py +++ b/setup.py @@ -3,6 +3,7 @@ with open("README.md", "r", encoding="utf-8") as fh: long_description = fh.read() +install_requires = ["argcomplete"] setuptools.setup( name="xkcd-pass", version="1.0.9", @@ -26,4 +27,5 @@ packages=setuptools.find_packages(where="src"), include_package_data=True, python_requires=">=3.6", + install_requires=install_requires, ) diff --git a/src/xkcd_pass/xkcd_pass.py b/src/xkcd_pass/xkcd_pass.py index 71a07a0..0a4b40c 100644 --- a/src/xkcd_pass/xkcd_pass.py +++ b/src/xkcd_pass/xkcd_pass.py @@ -11,6 +11,8 @@ from io import open from typing import Any, Callable, Dict, List, Optional, Union +import argcomplete + from xkcd_pass.lib.case import ( case_alternating, case_capitalize, @@ -489,6 +491,7 @@ def main() -> int: try: parser = xkcd_passArgumentParser() + argcomplete.autocomplete(parser) options = parser.parse_args() options.testing = False validate_options(options)