argcomplete 3.5.2__tar.gz → 3.5.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. argcomplete-3.5.3/.github/workflows/release.yml +21 -0
  2. {argcomplete-3.5.2 → argcomplete-3.5.3}/Changes.rst +8 -0
  3. {argcomplete-3.5.2/argcomplete.egg-info → argcomplete-3.5.3}/PKG-INFO +20 -19
  4. {argcomplete-3.5.2 → argcomplete-3.5.3}/README.rst +5 -2
  5. {argcomplete-3.5.2 → argcomplete-3.5.3}/argcomplete/completers.py +8 -4
  6. {argcomplete-3.5.2 → argcomplete-3.5.3}/common.mk +1 -6
  7. {argcomplete-3.5.2 → argcomplete-3.5.3}/pyproject.toml +7 -5
  8. argcomplete-3.5.3/setup.cfg +6 -0
  9. argcomplete-3.5.2/PKG-INFO +0 -351
  10. argcomplete-3.5.2/argcomplete.egg-info/SOURCES.txt +0 -64
  11. argcomplete-3.5.2/argcomplete.egg-info/dependency_links.txt +0 -1
  12. argcomplete-3.5.2/argcomplete.egg-info/entry_points.txt +0 -4
  13. argcomplete-3.5.2/argcomplete.egg-info/not-zip-safe +0 -1
  14. argcomplete-3.5.2/argcomplete.egg-info/requires.txt +0 -7
  15. argcomplete-3.5.2/argcomplete.egg-info/top_level.txt +0 -1
  16. argcomplete-3.5.2/setup.cfg +0 -11
  17. argcomplete-3.5.2/setup.py +0 -12
  18. argcomplete-3.5.2/test/test_package/test_module.py +0 -6
  19. argcomplete-3.5.2/test/test_package/test_package/__init__.py +0 -16
  20. argcomplete-3.5.2/test/test_package/test_package.egg-info/PKG-INFO +0 -3
  21. argcomplete-3.5.2/test/test_package/test_package.egg-info/SOURCES.txt +0 -8
  22. argcomplete-3.5.2/test/test_package/test_package.egg-info/dependency_links.txt +0 -1
  23. argcomplete-3.5.2/test/test_package/test_package.egg-info/entry_points.txt +0 -3
  24. argcomplete-3.5.2/test/test_package/test_package.egg-info/top_level.txt +0 -2
  25. {argcomplete-3.5.2 → argcomplete-3.5.3}/.github/FUNDING.yml +0 -0
  26. {argcomplete-3.5.2 → argcomplete-3.5.3}/.github/workflows/ci.yml +0 -0
  27. {argcomplete-3.5.2 → argcomplete-3.5.3}/.gitignore +0 -0
  28. {argcomplete-3.5.2 → argcomplete-3.5.3}/Authors.rst +0 -0
  29. {argcomplete-3.5.2 → argcomplete-3.5.3}/LICENSE.rst +0 -0
  30. {argcomplete-3.5.2 → argcomplete-3.5.3}/MANIFEST.in +0 -0
  31. {argcomplete-3.5.2 → argcomplete-3.5.3}/Makefile +0 -0
  32. {argcomplete-3.5.2 → argcomplete-3.5.3}/NOTICE +0 -0
  33. {argcomplete-3.5.2 → argcomplete-3.5.3}/SECURITY.md +0 -0
  34. {argcomplete-3.5.2 → argcomplete-3.5.3}/argcomplete/__init__.py +0 -0
  35. {argcomplete-3.5.2 → argcomplete-3.5.3}/argcomplete/_check_console_script.py +0 -0
  36. {argcomplete-3.5.2 → argcomplete-3.5.3}/argcomplete/_check_module.py +0 -0
  37. {argcomplete-3.5.2 → argcomplete-3.5.3}/argcomplete/bash_completion.d/_python-argcomplete +0 -0
  38. {argcomplete-3.5.2 → argcomplete-3.5.3}/argcomplete/exceptions.py +0 -0
  39. {argcomplete-3.5.2 → argcomplete-3.5.3}/argcomplete/finders.py +0 -0
  40. {argcomplete-3.5.2 → argcomplete-3.5.3}/argcomplete/io.py +0 -0
  41. {argcomplete-3.5.2 → argcomplete-3.5.3}/argcomplete/lexers.py +0 -0
  42. {argcomplete-3.5.2 → argcomplete-3.5.3}/argcomplete/packages/__init__.py +0 -0
  43. {argcomplete-3.5.2 → argcomplete-3.5.3}/argcomplete/packages/_argparse.py +0 -0
  44. {argcomplete-3.5.2 → argcomplete-3.5.3}/argcomplete/packages/_shlex.py +0 -0
  45. {argcomplete-3.5.2 → argcomplete-3.5.3}/argcomplete/py.typed +0 -0
  46. {argcomplete-3.5.2 → argcomplete-3.5.3}/argcomplete/scripts/__init__.py +0 -0
  47. {argcomplete-3.5.2 → argcomplete-3.5.3}/argcomplete/scripts/activate_global_python_argcomplete.py +0 -0
  48. {argcomplete-3.5.2 → argcomplete-3.5.3}/argcomplete/scripts/python_argcomplete_check_easy_install_script.py +0 -0
  49. {argcomplete-3.5.2 → argcomplete-3.5.3}/argcomplete/scripts/register_python_argcomplete.py +0 -0
  50. {argcomplete-3.5.2 → argcomplete-3.5.3}/argcomplete/shell_integration.py +0 -0
  51. {argcomplete-3.5.2 → argcomplete-3.5.3}/contrib/README.rst +0 -0
  52. {argcomplete-3.5.2 → argcomplete-3.5.3}/docs/changelog.rst +0 -0
  53. {argcomplete-3.5.2 → argcomplete-3.5.3}/docs/conf.py +0 -0
  54. {argcomplete-3.5.2 → argcomplete-3.5.3}/docs/examples/describe_github_user.py +0 -0
  55. {argcomplete-3.5.2 → argcomplete-3.5.3}/docs/fish_help_string.png +0 -0
  56. {argcomplete-3.5.2 → argcomplete-3.5.3}/docs/index.rst +0 -0
  57. {argcomplete-3.5.2 → argcomplete-3.5.3}/docs/toc.html +0 -0
  58. {argcomplete-3.5.2 → argcomplete-3.5.3}/test/__init__.py +0 -0
  59. {argcomplete-3.5.2 → argcomplete-3.5.3}/test/inputrc +0 -0
  60. {argcomplete-3.5.2 → argcomplete-3.5.3}/test/prog +0 -0
  61. {argcomplete-3.5.2 → argcomplete-3.5.3}/test/stuck +0 -0
  62. {argcomplete-3.5.2 → argcomplete-3.5.3}/test/test.py +0 -0
  63. {argcomplete-3.5.2 → argcomplete-3.5.3}/test/test_contrib_shells.py +0 -0
  64. {argcomplete-3.5.2 → argcomplete-3.5.3}/test/test_package/__init__.py +0 -0
  65. {argcomplete-3.5.2 → argcomplete-3.5.3}/test/test_package/setup.py +0 -0
  66. {argcomplete-3.5.2/test/test_package/build/lib → argcomplete-3.5.3/test/test_package}/test_module.py +0 -0
  67. {argcomplete-3.5.2/test/test_package/build/lib → argcomplete-3.5.3/test/test_package}/test_package/__init__.py +0 -0
@@ -0,0 +1,21 @@
1
+ name: Publish release to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v[0-9]+.[0-9]+.[0-9]+'
7
+
8
+ jobs:
9
+ pypi-publish:
10
+ name: Build and upload release to PyPI
11
+ runs-on: ubuntu-latest
12
+ environment: release
13
+ permissions:
14
+ id-token: write
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - uses: actions/setup-python@v4
18
+ - run: pip install build
19
+ - run: python -m build
20
+ - name: Publish package distributions to PyPI
21
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -1,8 +1,16 @@
1
+ Changes for v3.5.3 (2024-12-31)
2
+ ===============================
3
+
4
+ - Use interactive shells and bind to make environment variable name
5
+ completions work in older Bash versions (#506)
6
+
1
7
  Changes for v3.5.2 (2024-12-06)
2
8
  ===============================
3
9
 
4
10
  - Fix \_parse_known_args monkeypatching
5
11
 
12
+ - Note: This fix is required to restore compatibility with Python 3.12.8 and 3.13.1.
13
+
6
14
  - CI improvements
7
15
 
8
16
  Changes for v3.5.1 (2024-10-06)
@@ -1,17 +1,18 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: argcomplete
3
- Version: 3.5.2
3
+ Version: 3.5.3
4
4
  Summary: Bash tab completion for argparse
5
- Home-page: https://github.com/kislyuk/argcomplete
6
- Author: Andrey Kislyuk
7
- Author-email: kislyuk@gmail.com
8
- License: Apache Software License
5
+ Project-URL: Homepage, https://github.com/kislyuk/argcomplete
9
6
  Project-URL: Documentation, https://kislyuk.github.io/argcomplete
10
7
  Project-URL: Source Code, https://github.com/kislyuk/argcomplete
11
8
  Project-URL: Issue Tracker, https://github.com/kislyuk/argcomplete/issues
12
9
  Project-URL: Change Log, https://github.com/kislyuk/argcomplete/blob/develop/Changes.rst
13
- Platform: MacOS X
14
- Platform: Posix
10
+ Author: Andrey Kislyuk
11
+ Author-email: kislyuk@gmail.com
12
+ License: Apache Software License
13
+ License-File: LICENSE.rst
14
+ License-File: NOTICE
15
+ Classifier: Development Status :: 5 - Production/Stable
15
16
  Classifier: Environment :: Console
16
17
  Classifier: Intended Audience :: Developers
17
18
  Classifier: License :: OSI Approved :: Apache Software License
@@ -27,21 +28,18 @@ Classifier: Programming Language :: Python :: 3.11
27
28
  Classifier: Programming Language :: Python :: 3.12
28
29
  Classifier: Programming Language :: Python :: Implementation :: CPython
29
30
  Classifier: Programming Language :: Python :: Implementation :: PyPy
30
- Classifier: Development Status :: 5 - Production/Stable
31
31
  Classifier: Topic :: Software Development
32
32
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
33
33
  Classifier: Topic :: System :: Shells
34
34
  Classifier: Topic :: Terminals
35
35
  Requires-Python: >=3.8
36
- Description-Content-Type: text/x-rst
37
- License-File: LICENSE.rst
38
- License-File: NOTICE
39
36
  Provides-Extra: test
40
- Requires-Dist: coverage; extra == "test"
41
- Requires-Dist: pexpect; extra == "test"
42
- Requires-Dist: wheel; extra == "test"
43
- Requires-Dist: ruff; extra == "test"
44
- Requires-Dist: mypy; extra == "test"
37
+ Requires-Dist: coverage; extra == 'test'
38
+ Requires-Dist: mypy; extra == 'test'
39
+ Requires-Dist: pexpect; extra == 'test'
40
+ Requires-Dist: ruff; extra == 'test'
41
+ Requires-Dist: wheel; extra == 'test'
42
+ Description-Content-Type: text/x-rst
45
43
 
46
44
  argcomplete - Bash/zsh tab completion for argparse
47
45
  ==================================================
@@ -85,6 +83,9 @@ follows:
85
83
  args = parser.parse_args()
86
84
  ...
87
85
 
86
+ If using ``pyproject.toml`` ``[project.scripts]`` entry points, the ``PYTHON_ARGCOMPLETE_OK`` marker should appear
87
+ at the beginning of the file that contains the entry point.
88
+
88
89
  Register your Python application with your shell's completion framework by running ``register-python-argcomplete``::
89
90
 
90
91
  eval "$(register-python-argcomplete my-python-app)"
@@ -268,9 +269,9 @@ multiple Python versions on the same system, the version being used to run the s
268
269
  ``/etc/shells``, and run ``chsh`` to change your shell). You can check the version of the running copy of bash with
269
270
  ``echo $BASH_VERSION``.
270
271
 
271
- .. note:: If you use setuptools/distribute ``scripts`` or ``entry_points`` directives to package your module,
272
+ .. note:: If you use ``project.scripts`` directives to provide command line entry points to your package,
272
273
  argcomplete will follow the wrapper scripts to their destination and look for ``PYTHON_ARGCOMPLETE_OK`` in the
273
- destination code.
274
+ first kilobyte of the file containing the destination code.
274
275
 
275
276
  If you choose not to use global completion, or ship a completion module that depends on argcomplete, you must register
276
277
  your script explicitly using ``eval "$(register-python-argcomplete my-python-app)"``. Standard completion module
@@ -40,6 +40,9 @@ follows:
40
40
  args = parser.parse_args()
41
41
  ...
42
42
 
43
+ If using ``pyproject.toml`` ``[project.scripts]`` entry points, the ``PYTHON_ARGCOMPLETE_OK`` marker should appear
44
+ at the beginning of the file that contains the entry point.
45
+
43
46
  Register your Python application with your shell's completion framework by running ``register-python-argcomplete``::
44
47
 
45
48
  eval "$(register-python-argcomplete my-python-app)"
@@ -223,9 +226,9 @@ multiple Python versions on the same system, the version being used to run the s
223
226
  ``/etc/shells``, and run ``chsh`` to change your shell). You can check the version of the running copy of bash with
224
227
  ``echo $BASH_VERSION``.
225
228
 
226
- .. note:: If you use setuptools/distribute ``scripts`` or ``entry_points`` directives to package your module,
229
+ .. note:: If you use ``project.scripts`` directives to provide command line entry points to your package,
227
230
  argcomplete will follow the wrapper scripts to their destination and look for ``PYTHON_ARGCOMPLETE_OK`` in the
228
- destination code.
231
+ first kilobyte of the file containing the destination code.
229
232
 
230
233
  If you choose not to use global completion, or ship a completion module that depends on argcomplete, you must register
231
234
  your script explicitly using ``eval "$(register-python-argcomplete my-python-app)"``. Standard completion module
@@ -59,13 +59,17 @@ class FilesCompleter(BaseCompleter):
59
59
  completion = []
60
60
  if self.allowednames:
61
61
  if self.directories:
62
- files = _call(["bash", "-c", "compgen -A directory -- '{p}'".format(p=prefix)])
62
+ # Using 'bind' in this and the following commands is a workaround to a bug in bash
63
+ # that was fixed in bash 5.3 but affects older versions. Environment variables are not treated
64
+ # correctly in older versions and calling bind makes them available. For details, see
65
+ # https://savannah.gnu.org/support/index.php?111125
66
+ files = _call(["bash", "-c", "bind; compgen -A directory -- '{p}'".format(p=prefix)], stderr=subprocess.DEVNULL)
63
67
  completion += [f + "/" for f in files]
64
68
  for x in self.allowednames:
65
- completion += _call(["bash", "-c", "compgen -A file -X '!*.{0}' -- '{p}'".format(x, p=prefix)])
69
+ completion += _call(["bash", "-c", "bind; compgen -A file -X '!*.{0}' -- '{p}'".format(x, p=prefix)], stderr=subprocess.DEVNULL)
66
70
  else:
67
- completion += _call(["bash", "-c", "compgen -A file -- '{p}'".format(p=prefix)])
68
- anticomp = _call(["bash", "-c", "compgen -A directory -- '{p}'".format(p=prefix)])
71
+ completion += _call(["bash", "-c", "bind; compgen -A file -- '{p}'".format(p=prefix)], stderr=subprocess.DEVNULL)
72
+ anticomp = _call(["bash", "-c", "bind; compgen -A directory -- '{p}'".format(p=prefix)], stderr=subprocess.DEVNULL)
69
73
  completion = list(set(completion) - set(anticomp))
70
74
 
71
75
  if self.directories:
@@ -20,7 +20,7 @@ release:
20
20
  @if ! type -P gh; then echo "Please install gh"; exit 1; fi
21
21
  @if ! type -P twine; then echo "Please install twine"; exit 1; fi
22
22
  git pull
23
- git clean -x --force $$(python setup.py --name)
23
+ git clean -x --force argcomplete
24
24
  TAG_MSG=$$(mktemp); \
25
25
  echo "# Changes for ${TAG} ($$(date +%Y-%m-%d))" > $$TAG_MSG; \
26
26
  git log --pretty=format:%s $$(git describe --abbrev=0)..HEAD >> $$TAG_MSG; \
@@ -32,13 +32,8 @@ release:
32
32
  git push --follow-tags
33
33
  $(MAKE) install
34
34
  gh release create ${TAG} dist/*.whl --notes="$$(git tag --list ${TAG} -n99 | perl -pe 's/^\S+\s*// if $$. == 1' | sed 's/^\s\s\s\s//')"
35
- $(MAKE) release-pypi
36
35
  $(MAKE) release-docs
37
36
 
38
- release-pypi:
39
- python -m build
40
- twine upload dist/*.tar.gz dist/*.whl --verbose
41
-
42
37
  release-docs:
43
38
  $(MAKE) docs
44
39
  -git branch -D gh-pages
@@ -1,7 +1,3 @@
1
- [build-system]
2
- requires = ["setuptools>=67.7.2", "setuptools_scm[toml]>=6.2"]
3
- build-backend = "setuptools.build_meta"
4
-
5
1
  [project]
6
2
  name = "argcomplete"
7
3
  description = "Bash tab completion for argparse"
@@ -43,12 +39,18 @@ register-python-argcomplete = "argcomplete.scripts.register_python_argcomplete:m
43
39
  test = ["coverage", "pexpect", "wheel", "ruff", "mypy"]
44
40
 
45
41
  [project.urls]
42
+ "Homepage"= "https://github.com/kislyuk/argcomplete"
46
43
  "Documentation"= "https://kislyuk.github.io/argcomplete"
47
44
  "Source Code"= "https://github.com/kislyuk/argcomplete"
48
45
  "Issue Tracker"= "https://github.com/kislyuk/argcomplete/issues"
49
46
  "Change Log"= "https://github.com/kislyuk/argcomplete/blob/develop/Changes.rst"
50
47
 
51
- [tool.setuptools_scm]
48
+ [build-system]
49
+ requires = ["hatchling", "hatch-vcs"]
50
+ build-backend = "hatchling.build"
51
+
52
+ [tool.hatch.version]
53
+ source = "vcs"
52
54
 
53
55
  [tool.black]
54
56
  line-length = 120
@@ -0,0 +1,6 @@
1
+ [bdist_rpm]
2
+ provides=python-argcomplete
3
+ doc_files = Authors.rst
4
+ Changes.rst
5
+ README.rst
6
+ LICENSE.rst
@@ -1,351 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: argcomplete
3
- Version: 3.5.2
4
- Summary: Bash tab completion for argparse
5
- Home-page: https://github.com/kislyuk/argcomplete
6
- Author: Andrey Kislyuk
7
- Author-email: kislyuk@gmail.com
8
- License: Apache Software License
9
- Project-URL: Documentation, https://kislyuk.github.io/argcomplete
10
- Project-URL: Source Code, https://github.com/kislyuk/argcomplete
11
- Project-URL: Issue Tracker, https://github.com/kislyuk/argcomplete/issues
12
- Project-URL: Change Log, https://github.com/kislyuk/argcomplete/blob/develop/Changes.rst
13
- Platform: MacOS X
14
- Platform: Posix
15
- Classifier: Environment :: Console
16
- Classifier: Intended Audience :: Developers
17
- Classifier: License :: OSI Approved :: Apache Software License
18
- Classifier: Operating System :: MacOS :: MacOS X
19
- Classifier: Operating System :: POSIX
20
- Classifier: Programming Language :: Python
21
- Classifier: Programming Language :: Python :: 3
22
- Classifier: Programming Language :: Python :: 3.7
23
- Classifier: Programming Language :: Python :: 3.8
24
- Classifier: Programming Language :: Python :: 3.9
25
- Classifier: Programming Language :: Python :: 3.10
26
- Classifier: Programming Language :: Python :: 3.11
27
- Classifier: Programming Language :: Python :: 3.12
28
- Classifier: Programming Language :: Python :: Implementation :: CPython
29
- Classifier: Programming Language :: Python :: Implementation :: PyPy
30
- Classifier: Development Status :: 5 - Production/Stable
31
- Classifier: Topic :: Software Development
32
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
33
- Classifier: Topic :: System :: Shells
34
- Classifier: Topic :: Terminals
35
- Requires-Python: >=3.8
36
- Description-Content-Type: text/x-rst
37
- License-File: LICENSE.rst
38
- License-File: NOTICE
39
- Provides-Extra: test
40
- Requires-Dist: coverage; extra == "test"
41
- Requires-Dist: pexpect; extra == "test"
42
- Requires-Dist: wheel; extra == "test"
43
- Requires-Dist: ruff; extra == "test"
44
- Requires-Dist: mypy; extra == "test"
45
-
46
- argcomplete - Bash/zsh tab completion for argparse
47
- ==================================================
48
- *Tab complete all the things!*
49
-
50
- Argcomplete provides easy, extensible command line tab completion of arguments for your Python application.
51
-
52
- It makes two assumptions:
53
-
54
- * You're using bash or zsh as your shell
55
- * You're using `argparse <http://docs.python.org/3/library/argparse.html>`_ to manage your command line arguments/options
56
-
57
- Argcomplete is particularly useful if your program has lots of options or subparsers, and if your program can
58
- dynamically suggest completions for your argument/option values (for example, if the user is browsing resources over
59
- the network).
60
-
61
- Installation
62
- ------------
63
- ::
64
-
65
- pip install argcomplete
66
- activate-global-python-argcomplete
67
-
68
- See `Activating global completion`_ below for details about the second step.
69
-
70
- Refresh your shell environment (start a new shell).
71
-
72
- Synopsis
73
- --------
74
- Add the ``PYTHON_ARGCOMPLETE_OK`` marker and a call to ``argcomplete.autocomplete()`` to your Python application as
75
- follows:
76
-
77
- .. code-block:: python
78
-
79
- #!/usr/bin/env python
80
- # PYTHON_ARGCOMPLETE_OK
81
- import argcomplete, argparse
82
- parser = argparse.ArgumentParser()
83
- ...
84
- argcomplete.autocomplete(parser)
85
- args = parser.parse_args()
86
- ...
87
-
88
- Register your Python application with your shell's completion framework by running ``register-python-argcomplete``::
89
-
90
- eval "$(register-python-argcomplete my-python-app)"
91
-
92
- Quotes are significant; the registration will fail without them. See `Global completion`_ below for a way to enable
93
- argcomplete generally without registering each application individually.
94
-
95
- argcomplete.autocomplete(*parser*)
96
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
97
- This method is the entry point to the module. It must be called **after** ArgumentParser construction is complete, but
98
- **before** the ``ArgumentParser.parse_args()`` method is called. The method looks for an environment variable that the
99
- completion hook shellcode sets, and if it's there, collects completions, prints them to the output stream (fd 8 by
100
- default), and exits. Otherwise, it returns to the caller immediately.
101
-
102
- .. admonition:: Side effects
103
-
104
- Argcomplete gets completions by running your program. It intercepts the execution flow at the moment
105
- ``argcomplete.autocomplete()`` is called. After sending completions, it exits using ``exit_method`` (``os._exit``
106
- by default). This means if your program has any side effects that happen before ``argcomplete`` is called, those
107
- side effects will happen every time the user presses ``<TAB>`` (although anything your program prints to stdout or
108
- stderr will be suppressed). For this reason it's best to construct the argument parser and call
109
- ``argcomplete.autocomplete()`` as early as possible in your execution flow.
110
-
111
- .. admonition:: Performance
112
-
113
- If the program takes a long time to get to the point where ``argcomplete.autocomplete()`` is called, the tab completion
114
- process will feel sluggish, and the user may lose confidence in it. So it's also important to minimize the startup time
115
- of the program up to that point (for example, by deferring initialization or importing of large modules until after
116
- parsing options).
117
-
118
- Specifying completers
119
- ---------------------
120
- You can specify custom completion functions for your options and arguments. Two styles are supported: callable and
121
- readline-style. Callable completers are simpler. They are called with the following keyword arguments:
122
-
123
- * ``prefix``: The prefix text of the last word before the cursor on the command line.
124
- For dynamic completers, this can be used to reduce the work required to generate possible completions.
125
- * ``action``: The ``argparse.Action`` instance that this completer was called for.
126
- * ``parser``: The ``argparse.ArgumentParser`` instance that the action was taken by.
127
- * ``parsed_args``: The result of argument parsing so far (the ``argparse.Namespace`` args object normally returned by
128
- ``ArgumentParser.parse_args()``).
129
-
130
- Completers can return their completions as an iterable of strings or a mapping (dict) of strings to their
131
- descriptions (zsh will display the descriptions as context help alongside completions). An example completer for names
132
- of environment variables might look like this:
133
-
134
- .. code-block:: python
135
-
136
- def EnvironCompleter(**kwargs):
137
- return os.environ
138
-
139
- To specify a completer for an argument or option, set the ``completer`` attribute of its associated action. An easy
140
- way to do this at definition time is:
141
-
142
- .. code-block:: python
143
-
144
- from argcomplete.completers import EnvironCompleter
145
-
146
- parser = argparse.ArgumentParser()
147
- parser.add_argument("--env-var1").completer = EnvironCompleter
148
- parser.add_argument("--env-var2").completer = EnvironCompleter
149
- argcomplete.autocomplete(parser)
150
-
151
- If you specify the ``choices`` keyword for an argparse option or argument (and don't specify a completer), it will be
152
- used for completions.
153
-
154
- A completer that is initialized with a set of all possible choices of values for its action might look like this:
155
-
156
- .. code-block:: python
157
-
158
- class ChoicesCompleter(object):
159
- def __init__(self, choices):
160
- self.choices = choices
161
-
162
- def __call__(self, **kwargs):
163
- return self.choices
164
-
165
- The following two ways to specify a static set of choices are equivalent for completion purposes:
166
-
167
- .. code-block:: python
168
-
169
- from argcomplete.completers import ChoicesCompleter
170
-
171
- parser.add_argument("--protocol", choices=('http', 'https', 'ssh', 'rsync', 'wss'))
172
- parser.add_argument("--proto").completer=ChoicesCompleter(('http', 'https', 'ssh', 'rsync', 'wss'))
173
-
174
- Note that if you use the ``choices=<completions>`` option, argparse will show
175
- all these choices in the ``--help`` output by default. To prevent this, set
176
- ``metavar`` (like ``parser.add_argument("--protocol", metavar="PROTOCOL",
177
- choices=('http', 'https', 'ssh', 'rsync', 'wss'))``).
178
-
179
- The following `script <https://raw.github.com/kislyuk/argcomplete/master/docs/examples/describe_github_user.py>`_ uses
180
- ``parsed_args`` and `Requests <http://python-requests.org/>`_ to query GitHub for publicly known members of an
181
- organization and complete their names, then prints the member description:
182
-
183
- .. code-block:: python
184
-
185
- #!/usr/bin/env python
186
- # PYTHON_ARGCOMPLETE_OK
187
- import argcomplete, argparse, requests, pprint
188
-
189
- def github_org_members(prefix, parsed_args, **kwargs):
190
- resource = "https://api.github.com/orgs/{org}/members".format(org=parsed_args.organization)
191
- return (member['login'] for member in requests.get(resource).json() if member['login'].startswith(prefix))
192
-
193
- parser = argparse.ArgumentParser()
194
- parser.add_argument("--organization", help="GitHub organization")
195
- parser.add_argument("--member", help="GitHub member").completer = github_org_members
196
-
197
- argcomplete.autocomplete(parser)
198
- args = parser.parse_args()
199
-
200
- pprint.pprint(requests.get("https://api.github.com/users/{m}".format(m=args.member)).json())
201
-
202
- `Try it <https://raw.github.com/kislyuk/argcomplete/master/docs/examples/describe_github_user.py>`_ like this::
203
-
204
- ./describe_github_user.py --organization heroku --member <TAB>
205
-
206
- If you have a useful completer to add to the `completer library
207
- <https://github.com/kislyuk/argcomplete/blob/master/argcomplete/completers.py>`_, send a pull request!
208
-
209
- Readline-style completers
210
- ~~~~~~~~~~~~~~~~~~~~~~~~~
211
- The readline_ module defines a completer protocol in rlcompleter_. Readline-style completers are also supported by
212
- argcomplete, so you can use the same completer object both in an interactive readline-powered shell and on the command
213
- line. For example, you can use the readline-style completer provided by IPython_ to get introspective completions like
214
- you would get in the IPython shell:
215
-
216
- .. _readline: http://docs.python.org/3/library/readline.html
217
- .. _rlcompleter: http://docs.python.org/3/library/rlcompleter.html#completer-objects
218
- .. _IPython: http://ipython.org/
219
-
220
- .. code-block:: python
221
-
222
- import IPython
223
- parser.add_argument("--python-name").completer = IPython.core.completer.Completer()
224
-
225
- ``argcomplete.CompletionFinder.rl_complete`` can also be used to plug in an argparse parser as a readline completer.
226
-
227
- Printing warnings in completers
228
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
229
- Normal stdout/stderr output is suspended when argcomplete runs. Sometimes, though, when the user presses ``<TAB>``, it's
230
- appropriate to print information about why completions generation failed. To do this, use ``warn``:
231
-
232
- .. code-block:: python
233
-
234
- from argcomplete import warn
235
-
236
- def AwesomeWebServiceCompleter(prefix, **kwargs):
237
- if login_failed:
238
- warn("Please log in to Awesome Web Service to use autocompletion")
239
- return completions
240
-
241
- Using a custom completion validator
242
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
243
- By default, argcomplete validates your completions by checking if they start with the prefix given to the completer. You
244
- can override this validation check by supplying the ``validator`` keyword to ``argcomplete.autocomplete()``:
245
-
246
- .. code-block:: python
247
-
248
- def my_validator(completion_candidate, current_input):
249
- """Complete non-prefix substring matches."""
250
- return current_input in completion_candidate
251
-
252
- argcomplete.autocomplete(parser, validator=my_validator)
253
-
254
- Global completion
255
- -----------------
256
- In global completion mode, you don't have to register each argcomplete-capable executable separately. Instead, the shell
257
- will look for the string **PYTHON_ARGCOMPLETE_OK** in the first 1024 bytes of any executable that it's running
258
- completion for, and if it's found, follow the rest of the argcomplete protocol as described above.
259
-
260
- Additionally, completion is activated for scripts run as ``python <script>`` and ``python -m <module>``. If you're using
261
- multiple Python versions on the same system, the version being used to run the script must have argcomplete installed.
262
-
263
- .. admonition:: Bash version compatibility
264
-
265
- When using bash, global completion requires bash support for ``complete -D``, which was introduced in bash 4.2. Since
266
- Mac OS ships with an outdated version of Bash (3.2), you can either use zsh or install a newer version of bash using
267
- `Homebrew <http://brew.sh/>`_ (``brew install bash`` - you will also need to add ``/opt/homebrew/bin/bash`` to
268
- ``/etc/shells``, and run ``chsh`` to change your shell). You can check the version of the running copy of bash with
269
- ``echo $BASH_VERSION``.
270
-
271
- .. note:: If you use setuptools/distribute ``scripts`` or ``entry_points`` directives to package your module,
272
- argcomplete will follow the wrapper scripts to their destination and look for ``PYTHON_ARGCOMPLETE_OK`` in the
273
- destination code.
274
-
275
- If you choose not to use global completion, or ship a completion module that depends on argcomplete, you must register
276
- your script explicitly using ``eval "$(register-python-argcomplete my-python-app)"``. Standard completion module
277
- registration rules apply: namely, the script name is passed directly to ``complete``, meaning it is only tab completed
278
- when invoked exactly as it was registered. In the above example, ``my-python-app`` must be on the path, and the user
279
- must be attempting to complete it by that name. The above line alone would **not** allow you to complete
280
- ``./my-python-app``, or ``/path/to/my-python-app``.
281
-
282
- Activating global completion
283
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
284
- The script ``activate-global-python-argcomplete`` installs the global completion script
285
- `bash_completion.d/_python-argcomplete <https://github.com/kislyuk/argcomplete/blob/master/argcomplete/bash_completion.d/_python-argcomplete>`_
286
- into an appropriate location on your system for both bash and zsh. The specific location depends on your platform and
287
- whether you installed argcomplete system-wide using ``sudo`` or locally (into your user's home directory).
288
-
289
- Zsh Support
290
- -----------
291
- Argcomplete supports zsh. On top of plain completions like in bash, zsh allows you to see argparse help strings as
292
- completion descriptions. All shellcode included with argcomplete is compatible with both bash and zsh, so the same
293
- completer commands ``activate-global-python-argcomplete`` and ``eval "$(register-python-argcomplete my-python-app)"``
294
- work for zsh as well.
295
-
296
- Python Support
297
- --------------
298
- Argcomplete requires Python 3.7+.
299
-
300
- Support for other shells
301
- ------------------------
302
- Argcomplete maintainers provide support only for the bash and zsh shells on Linux and MacOS. For resources related to
303
- other shells and platforms, including fish, tcsh, xonsh, powershell, and Windows, please see the
304
- `contrib <https://github.com/kislyuk/argcomplete/tree/develop/contrib>`_ directory.
305
-
306
- Common Problems
307
- ---------------
308
- If global completion is not completing your script, bash may have registered a default completion function::
309
-
310
- $ complete | grep my-python-app
311
- complete -F _minimal my-python-app
312
-
313
- You can fix this by restarting your shell, or by running ``complete -r my-python-app``.
314
-
315
- Debugging
316
- ---------
317
- Set the ``_ARC_DEBUG`` variable in your shell to enable verbose debug output every time argcomplete runs. This will
318
- disrupt the command line composition state of your terminal, but make it possible to see the internal state of the
319
- completer if it encounters problems.
320
-
321
- Acknowledgments
322
- ---------------
323
- Inspired and informed by the optcomplete_ module by Martin Blais.
324
-
325
- .. _optcomplete: http://pypi.python.org/pypi/optcomplete
326
-
327
- Links
328
- -----
329
- * `Project home page (GitHub) <https://github.com/kislyuk/argcomplete>`_
330
- * `Documentation <https://kislyuk.github.io/argcomplete/>`_
331
- * `Package distribution (PyPI) <https://pypi.python.org/pypi/argcomplete>`_
332
- * `Change log <https://github.com/kislyuk/argcomplete/blob/master/Changes.rst>`_
333
-
334
- Bugs
335
- ~~~~
336
- Please report bugs, issues, feature requests, etc. on `GitHub <https://github.com/kislyuk/argcomplete/issues>`_.
337
-
338
- License
339
- -------
340
- Copyright 2012-2023, Andrey Kislyuk and argcomplete contributors. Licensed under the terms of the
341
- `Apache License, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0>`_. Distribution of the LICENSE and NOTICE
342
- files with source copies of this package and derivative works is **REQUIRED** as specified by the Apache License.
343
-
344
- .. image:: https://github.com/kislyuk/argcomplete/workflows/Python%20package/badge.svg
345
- :target: https://github.com/kislyuk/argcomplete/actions
346
- .. image:: https://codecov.io/github/kislyuk/argcomplete/coverage.svg?branch=master
347
- :target: https://codecov.io/github/kislyuk/argcomplete?branch=master
348
- .. image:: https://img.shields.io/pypi/v/argcomplete.svg
349
- :target: https://pypi.python.org/pypi/argcomplete
350
- .. image:: https://img.shields.io/pypi/l/argcomplete.svg
351
- :target: https://pypi.python.org/pypi/argcomplete
@@ -1,64 +0,0 @@
1
- .gitignore
2
- Authors.rst
3
- Changes.rst
4
- LICENSE.rst
5
- MANIFEST.in
6
- Makefile
7
- NOTICE
8
- README.rst
9
- SECURITY.md
10
- common.mk
11
- pyproject.toml
12
- setup.cfg
13
- setup.py
14
- .github/FUNDING.yml
15
- .github/workflows/ci.yml
16
- argcomplete/__init__.py
17
- argcomplete/_check_console_script.py
18
- argcomplete/_check_module.py
19
- argcomplete/completers.py
20
- argcomplete/exceptions.py
21
- argcomplete/finders.py
22
- argcomplete/io.py
23
- argcomplete/lexers.py
24
- argcomplete/py.typed
25
- argcomplete/shell_integration.py
26
- argcomplete.egg-info/PKG-INFO
27
- argcomplete.egg-info/SOURCES.txt
28
- argcomplete.egg-info/dependency_links.txt
29
- argcomplete.egg-info/entry_points.txt
30
- argcomplete.egg-info/not-zip-safe
31
- argcomplete.egg-info/requires.txt
32
- argcomplete.egg-info/top_level.txt
33
- argcomplete/bash_completion.d/_python-argcomplete
34
- argcomplete/packages/__init__.py
35
- argcomplete/packages/_argparse.py
36
- argcomplete/packages/_shlex.py
37
- argcomplete/scripts/__init__.py
38
- argcomplete/scripts/activate_global_python_argcomplete.py
39
- argcomplete/scripts/python_argcomplete_check_easy_install_script.py
40
- argcomplete/scripts/register_python_argcomplete.py
41
- contrib/README.rst
42
- docs/changelog.rst
43
- docs/conf.py
44
- docs/fish_help_string.png
45
- docs/index.rst
46
- docs/toc.html
47
- docs/examples/describe_github_user.py
48
- test/__init__.py
49
- test/inputrc
50
- test/prog
51
- test/stuck
52
- test/test.py
53
- test/test_contrib_shells.py
54
- test/test_package/__init__.py
55
- test/test_package/setup.py
56
- test/test_package/test_module.py
57
- test/test_package/build/lib/test_module.py
58
- test/test_package/build/lib/test_package/__init__.py
59
- test/test_package/test_package/__init__.py
60
- test/test_package/test_package.egg-info/PKG-INFO
61
- test/test_package/test_package.egg-info/SOURCES.txt
62
- test/test_package/test_package.egg-info/dependency_links.txt
63
- test/test_package/test_package.egg-info/entry_points.txt
64
- test/test_package/test_package.egg-info/top_level.txt
@@ -1,4 +0,0 @@
1
- [console_scripts]
2
- activate-global-python-argcomplete = argcomplete.scripts.activate_global_python_argcomplete:main
3
- python-argcomplete-check-easy-install-script = argcomplete.scripts.python_argcomplete_check_easy_install_script:main
4
- register-python-argcomplete = argcomplete.scripts.register_python_argcomplete:main
@@ -1,7 +0,0 @@
1
-
2
- [test]
3
- coverage
4
- pexpect
5
- wheel
6
- ruff
7
- mypy
@@ -1 +0,0 @@
1
- argcomplete
@@ -1,11 +0,0 @@
1
- [bdist_rpm]
2
- provides = python-argcomplete
3
- doc_files = Authors.rst
4
- Changes.rst
5
- README.rst
6
- LICENSE.rst
7
-
8
- [egg_info]
9
- tag_build =
10
- tag_date = 0
11
-
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env python
2
-
3
- from setuptools import find_packages, setup
4
-
5
- setup(
6
- url="https://github.com/kislyuk/argcomplete",
7
- packages=find_packages(exclude=["test", "test.*"]),
8
- package_data={"argcomplete": ["bash_completion.d/_python-argcomplete", "py.typed"]},
9
- zip_safe=False,
10
- include_package_data=True,
11
- platforms=["MacOS X", "Posix"],
12
- )
@@ -1,6 +0,0 @@
1
- # PYTHON_ARGCOMPLETE_OK
2
-
3
- from test_package import main
4
-
5
- if __name__ == "__main__":
6
- main()
@@ -1,16 +0,0 @@
1
- # PYTHON_ARGCOMPLETE_OK
2
- import argparse
3
-
4
- import argcomplete
5
-
6
-
7
- def main():
8
- parser = argparse.ArgumentParser()
9
- parser.add_argument("arg", choices=["arg"])
10
- argcomplete.autocomplete(parser)
11
- args = parser.parse_args()
12
- print(args.arg)
13
-
14
-
15
- if __name__ == "__main__":
16
- main()
@@ -1,3 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: test-package
3
- Version: 0
@@ -1,8 +0,0 @@
1
- setup.py
2
- test_module.py
3
- test_package/__init__.py
4
- test_package.egg-info/PKG-INFO
5
- test_package.egg-info/SOURCES.txt
6
- test_package.egg-info/dependency_links.txt
7
- test_package.egg-info/entry_points.txt
8
- test_package.egg-info/top_level.txt
@@ -1,3 +0,0 @@
1
- [console_scripts]
2
- test-module = test_module:main
3
- test-package = test_package:main
@@ -1,2 +0,0 @@
1
- test_module
2
- test_package
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes