shtab


Nameshtab JSON
Version 1.7.1 PyPI version JSON
download
home_page
SummaryAutomagic shell tab completion for Python CLI applications
upload_time2024-03-07 18:51:10
maintainer
docs_urlNone
author
requires_python>=3.7
licenseApache-2.0
keywords tab complete completion shell bash zsh argparse
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            |Logo|

shtab
=====

|PyPI-Downloads| |Tests| |Coverage| |PyPI| |Conda|

- What: Automatically generate shell tab completion scripts for Python CLI apps
- Why: Speed & correctness. Alternatives like
  `argcomplete <https://pypi.org/project/argcomplete>`_ and
  `pyzshcomplete <https://pypi.org/project/pyzshcomplete>`_ are slow and have
  side-effects
- How: ``shtab`` processes an ``argparse.ArgumentParser`` object to generate a
  tab completion script for your shell

Features
--------

- Outputs tab completion scripts for

  - ``bash``
  - ``zsh``
  - ``tcsh``

- Supports

  - `argparse <https://docs.python.org/library/argparse>`_
  - `docopt <https://pypi.org/project/docopt>`_ (via `argopt <https://pypi.org/project/argopt>`_)

- Supports arguments, options and subparsers
- Supports choices (e.g. ``--say={hello,goodbye}``)
- Supports file and directory path completion
- Supports custom path completion (e.g. ``--file={*.txt}``)

------------------------------------------

.. contents:: Table of Contents
   :backlinks: top

Installation
------------

Choose one of:

- ``pip install shtab``, or
- ``conda install -c conda-forge shtab``

See `operating system-specific instructions in the docs <https://docs.iterative.ai/shtab/#installation>`_.

Usage
-----

There are two ways of using ``shtab``:

- `CLI Usage <https://docs.iterative.ai/shtab/use/#cli-usage>`_: ``shtab``'s own CLI interface for external applications

  - may not require any code modifications whatsoever
  - end-users execute ``shtab your_cli_app.your_parser_object``

- `Library Usage <https://docs.iterative.ai/shtab/use/#library-usage>`_: as a library integrated into your CLI application

  - adds a couple of lines to your application
  - argument mode: end-users execute ``your_cli_app --print-completion {bash,zsh,tcsh}``
  - subparser mode: end-users execute ``your_cli_app completion {bash,zsh,tcsh}``

Examples
--------

See `the docs for usage examples <https://docs.iterative.ai/shtab/use/#main.py>`_.

FAQs
----

Not working? Check out `frequently asked questions <https://docs.iterative.ai/shtab/#faqs>`_.

Alternatives
------------

- `argcomplete <https://pypi.org/project/argcomplete>`_

  - executes the underlying script *every* time ``<TAB>`` is pressed (slow and
    has side-effects)
  - only provides ``bash`` completion

- `pyzshcomplete <https://pypi.org/project/pyzshcomplete>`_

  - executes the underlying script *every* time ``<TAB>`` is pressed (slow and
    has side-effects)
  - only provides ``zsh`` completion

- `click <https://pypi.org/project/click>`_

  - different framework completely replacing the builtin ``argparse``
  - solves multiple problems (rather than POSIX-style "do one thing well")

Contributions
-------------

Please do open `issues <https://github.com/iterative/shtab/issues>`_ & `pull requests <https://github.com/iterative/shtab/pulls>`_! Some ideas:

- support ``fish``
- support ``powershell``

See
`CONTRIBUTING.md <https://github.com/iterative/shtab/tree/main/CONTRIBUTING.md>`_
for more guidance.

|Hits|

.. |Logo| image:: https://github.com/iterative/shtab/raw/main/meta/logo.png
.. |Tests| image:: https://img.shields.io/github/actions/workflow/status/iterative/shtab/test.yml?logo=github&label=tests
   :target: https://github.com/iterative/shtab/actions
   :alt: Tests
.. |Coverage| image:: https://codecov.io/gh/iterative/shtab/branch/main/graph/badge.svg
   :target: https://codecov.io/gh/iterative/shtab
   :alt: Coverage
.. |Conda| image:: https://img.shields.io/conda/v/conda-forge/shtab.svg?label=conda&logo=conda-forge
   :target: https://anaconda.org/conda-forge/shtab
   :alt: conda-forge
.. |PyPI| image:: https://img.shields.io/pypi/v/shtab.svg?label=pip&logo=PyPI&logoColor=white
   :target: https://pypi.org/project/shtab
   :alt: PyPI
.. |PyPI-Downloads| image:: https://img.shields.io/pypi/dm/shtab.svg?label=pypi%20downloads&logo=PyPI&logoColor=white
   :target: https://pepy.tech/project/shtab
   :alt: Downloads
.. |Hits| image:: https://caspersci.uk.to/cgi-bin/hits.cgi?q=shtab&style=social&r=https://github.com/iterative/shtab&a=hidden
   :target: https://caspersci.uk.to/cgi-bin/hits.cgi?q=shtab&a=plot&r=https://github.com/iterative/shtab&style=social
   :alt: Hits

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "shtab",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "Iterative <support@iterative.ai>",
    "keywords": "tab,complete,completion,shell,bash,zsh,argparse",
    "author": "",
    "author_email": "Casper da Costa-Luis <casper.dcl@physics.org>",
    "download_url": "https://files.pythonhosted.org/packages/a9/e4/13bf30c7c30ab86a7bc4104b1c943ff2f56c1a07c6d82a71ad034bcef1dc/shtab-1.7.1.tar.gz",
    "platform": null,
    "description": "|Logo|\n\nshtab\n=====\n\n|PyPI-Downloads| |Tests| |Coverage| |PyPI| |Conda|\n\n- What: Automatically generate shell tab completion scripts for Python CLI apps\n- Why: Speed & correctness. Alternatives like\n  `argcomplete <https://pypi.org/project/argcomplete>`_ and\n  `pyzshcomplete <https://pypi.org/project/pyzshcomplete>`_ are slow and have\n  side-effects\n- How: ``shtab`` processes an ``argparse.ArgumentParser`` object to generate a\n  tab completion script for your shell\n\nFeatures\n--------\n\n- Outputs tab completion scripts for\n\n  - ``bash``\n  - ``zsh``\n  - ``tcsh``\n\n- Supports\n\n  - `argparse <https://docs.python.org/library/argparse>`_\n  - `docopt <https://pypi.org/project/docopt>`_ (via `argopt <https://pypi.org/project/argopt>`_)\n\n- Supports arguments, options and subparsers\n- Supports choices (e.g. ``--say={hello,goodbye}``)\n- Supports file and directory path completion\n- Supports custom path completion (e.g. ``--file={*.txt}``)\n\n------------------------------------------\n\n.. contents:: Table of Contents\n   :backlinks: top\n\nInstallation\n------------\n\nChoose one of:\n\n- ``pip install shtab``, or\n- ``conda install -c conda-forge shtab``\n\nSee `operating system-specific instructions in the docs <https://docs.iterative.ai/shtab/#installation>`_.\n\nUsage\n-----\n\nThere are two ways of using ``shtab``:\n\n- `CLI Usage <https://docs.iterative.ai/shtab/use/#cli-usage>`_: ``shtab``'s own CLI interface for external applications\n\n  - may not require any code modifications whatsoever\n  - end-users execute ``shtab your_cli_app.your_parser_object``\n\n- `Library Usage <https://docs.iterative.ai/shtab/use/#library-usage>`_: as a library integrated into your CLI application\n\n  - adds a couple of lines to your application\n  - argument mode: end-users execute ``your_cli_app --print-completion {bash,zsh,tcsh}``\n  - subparser mode: end-users execute ``your_cli_app completion {bash,zsh,tcsh}``\n\nExamples\n--------\n\nSee `the docs for usage examples <https://docs.iterative.ai/shtab/use/#main.py>`_.\n\nFAQs\n----\n\nNot working? Check out `frequently asked questions <https://docs.iterative.ai/shtab/#faqs>`_.\n\nAlternatives\n------------\n\n- `argcomplete <https://pypi.org/project/argcomplete>`_\n\n  - executes the underlying script *every* time ``<TAB>`` is pressed (slow and\n    has side-effects)\n  - only provides ``bash`` completion\n\n- `pyzshcomplete <https://pypi.org/project/pyzshcomplete>`_\n\n  - executes the underlying script *every* time ``<TAB>`` is pressed (slow and\n    has side-effects)\n  - only provides ``zsh`` completion\n\n- `click <https://pypi.org/project/click>`_\n\n  - different framework completely replacing the builtin ``argparse``\n  - solves multiple problems (rather than POSIX-style \"do one thing well\")\n\nContributions\n-------------\n\nPlease do open `issues <https://github.com/iterative/shtab/issues>`_ & `pull requests <https://github.com/iterative/shtab/pulls>`_! Some ideas:\n\n- support ``fish``\n- support ``powershell``\n\nSee\n`CONTRIBUTING.md <https://github.com/iterative/shtab/tree/main/CONTRIBUTING.md>`_\nfor more guidance.\n\n|Hits|\n\n.. |Logo| image:: https://github.com/iterative/shtab/raw/main/meta/logo.png\n.. |Tests| image:: https://img.shields.io/github/actions/workflow/status/iterative/shtab/test.yml?logo=github&label=tests\n   :target: https://github.com/iterative/shtab/actions\n   :alt: Tests\n.. |Coverage| image:: https://codecov.io/gh/iterative/shtab/branch/main/graph/badge.svg\n   :target: https://codecov.io/gh/iterative/shtab\n   :alt: Coverage\n.. |Conda| image:: https://img.shields.io/conda/v/conda-forge/shtab.svg?label=conda&logo=conda-forge\n   :target: https://anaconda.org/conda-forge/shtab\n   :alt: conda-forge\n.. |PyPI| image:: https://img.shields.io/pypi/v/shtab.svg?label=pip&logo=PyPI&logoColor=white\n   :target: https://pypi.org/project/shtab\n   :alt: PyPI\n.. |PyPI-Downloads| image:: https://img.shields.io/pypi/dm/shtab.svg?label=pypi%20downloads&logo=PyPI&logoColor=white\n   :target: https://pepy.tech/project/shtab\n   :alt: Downloads\n.. |Hits| image:: https://caspersci.uk.to/cgi-bin/hits.cgi?q=shtab&style=social&r=https://github.com/iterative/shtab&a=hidden\n   :target: https://caspersci.uk.to/cgi-bin/hits.cgi?q=shtab&a=plot&r=https://github.com/iterative/shtab&style=social\n   :alt: Hits\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Automagic shell tab completion for Python CLI applications",
    "version": "1.7.1",
    "project_urls": {
        "changelog": "https://github.com/iterative/shtab/releases",
        "documentation": "https://docs.iterative.ai/shtab",
        "repository": "https://github.com/iterative/shtab"
    },
    "split_keywords": [
        "tab",
        "complete",
        "completion",
        "shell",
        "bash",
        "zsh",
        "argparse"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e2d1a1d3189e7873408b9dc396aef0d7926c198b0df2aa3ddb5b539d3e89a70f",
                "md5": "3e86a240d7cc664592d78c7c2415b31e",
                "sha256": "32d3d2ff9022d4c77a62492b6ec875527883891e33c6b479ba4d41a51e259983"
            },
            "downloads": -1,
            "filename": "shtab-1.7.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3e86a240d7cc664592d78c7c2415b31e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 14095,
            "upload_time": "2024-03-07T18:51:04",
            "upload_time_iso_8601": "2024-03-07T18:51:04.781562Z",
            "url": "https://files.pythonhosted.org/packages/e2/d1/a1d3189e7873408b9dc396aef0d7926c198b0df2aa3ddb5b539d3e89a70f/shtab-1.7.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a9e413bf30c7c30ab86a7bc4104b1c943ff2f56c1a07c6d82a71ad034bcef1dc",
                "md5": "da7bd07a2b2888974d6bf5c4ea70cdcf",
                "sha256": "4e4bcb02eeb82ec45920a5d0add92eac9c9b63b2804c9196c1f1fdc2d039243c"
            },
            "downloads": -1,
            "filename": "shtab-1.7.1.tar.gz",
            "has_sig": false,
            "md5_digest": "da7bd07a2b2888974d6bf5c4ea70cdcf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 45410,
            "upload_time": "2024-03-07T18:51:10",
            "upload_time_iso_8601": "2024-03-07T18:51:10.520993Z",
            "url": "https://files.pythonhosted.org/packages/a9/e4/13bf30c7c30ab86a7bc4104b1c943ff2f56c1a07c6d82a71ad034bcef1dc/shtab-1.7.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-07 18:51:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "iterative",
    "github_project": "shtab",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "shtab"
}
        
Elapsed time: 0.75202s