click-option-group


Nameclick-option-group JSON
Version 0.5.9 PyPI version JSON
download
home_pageNone
SummaryOption groups missing in Click
upload_time2025-10-09 09:38:01
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # click-option-group

[![PyPI version](https://img.shields.io/pypi/v/click-option-group.svg)](https://pypi.python.org/pypi/click-option-group)
[![Build status](https://travis-ci.org/click-contrib/click-option-group.svg?branch=master)](https://travis-ci.org/click-contrib/click-option-group)
[![Coverage Status](https://coveralls.io/repos/github/click-contrib/click-option-group/badge.svg?branch=master)](https://coveralls.io/github/click-contrib/click-option-group?branch=master)
![Supported Python versions](https://img.shields.io/pypi/pyversions/click-option-group.svg)
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)


**click-option-group** is a Click-extension package that adds option groups
missing in [Click](https://github.com/pallets/click/).

## Aim and Motivation

Click is a package for creating powerful and beautiful command line interfaces (CLI) in Python,
but it has no the functionality for creating option groups.

Option groups are convenient mechanism for logical structuring CLI, also it allows you to set
the specific behavior and set the relationship among grouped options (mutually exclusive options for example).
Moreover, [argparse](https://docs.python.org/3/library/argparse.html) stdlib package contains this
functionality out of the box.

At the same time, many Click users need this functionality.
You can read interesting discussions about it in the following issues:

* [issue 257](https://github.com/pallets/click/issues/257)
* [issue 373](https://github.com/pallets/click/issues/373)
* [issue 509](https://github.com/pallets/click/issues/509)
* [issue 1137](https://github.com/pallets/click/issues/1137)

The aim of this package is to provide group options with extensible functionality
using canonical and clean API (Click-like API as far as possible).

## Quickstart

### Installing

Install and update using pip:

```bash
pip install -U click-option-group
```

### A Simple Example

Here is a simple example how to use option groups in your Click-based CLI.
Just use `optgroup` for declaring option groups by decorating
your command function in Click-like API style.

```python
# app.py

import click
from click_option_group import optgroup, RequiredMutuallyExclusiveOptionGroup

@click.command()
@optgroup.group('Server configuration',
                help='The configuration of some server connection')
@optgroup.option('-h', '--host', default='localhost', help='Server host name')
@optgroup.option('-p', '--port', type=int, default=8888, help='Server port')
@optgroup.option('-n', '--attempts', type=int, default=3, help='The number of connection attempts')
@optgroup.option('-t', '--timeout', type=int, default=30, help='The server response timeout')
@optgroup.group('Input data sources', cls=RequiredMutuallyExclusiveOptionGroup,
                help='The sources of the input data')
@optgroup.option('--tsv-file', type=click.File(), help='CSV/TSV input data file')
@optgroup.option('--json-file', type=click.File(), help='JSON input data file')
@click.option('--debug/--no-debug', default=False, help='Debug flag')
def cli(**params):
    print(params)

if __name__ == '__main__':
    cli()
```

```bash
$ python app.py --help
Usage: app.py [OPTIONS]

Options:
  Server configuration:           The configuration of some server connection
    -h, --host TEXT               Server host name
    -p, --port INTEGER            Server port
    -n, --attempts INTEGER        The number of connection attempts
    -t, --timeout INTEGER         The server response timeout
  Input data sources: [mutually_exclusive, required]
                                  The sources of the input data
    --tsv-file FILENAME           CSV/TSV input data file
    --json-file FILENAME          JSON input data file
  --debug / --no-debug            Debug flag
  --help                          Show this message and exit.
```

## Documentation

https://click-option-group.readthedocs.io

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "click-option-group",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Eugene Prilepin <esp.home@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/ef/ff/d291d66595b30b83d1cb9e314b2c9be7cfc7327d4a0d40a15da2416ea97b/click_option_group-0.5.9.tar.gz",
    "platform": null,
    "description": "# click-option-group\n\n[![PyPI version](https://img.shields.io/pypi/v/click-option-group.svg)](https://pypi.python.org/pypi/click-option-group)\n[![Build status](https://travis-ci.org/click-contrib/click-option-group.svg?branch=master)](https://travis-ci.org/click-contrib/click-option-group)\n[![Coverage Status](https://coveralls.io/repos/github/click-contrib/click-option-group/badge.svg?branch=master)](https://coveralls.io/github/click-contrib/click-option-group?branch=master)\n![Supported Python versions](https://img.shields.io/pypi/pyversions/click-option-group.svg)\n[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)\n\n\n**click-option-group** is a Click-extension package that adds option groups\nmissing in [Click](https://github.com/pallets/click/).\n\n## Aim and Motivation\n\nClick is a package for creating powerful and beautiful command line interfaces (CLI) in Python,\nbut it has no the functionality for creating option groups.\n\nOption groups are convenient mechanism for logical structuring CLI, also it allows you to set\nthe specific behavior and set the relationship among grouped options (mutually exclusive options for example).\nMoreover, [argparse](https://docs.python.org/3/library/argparse.html) stdlib package contains this\nfunctionality out of the box.\n\nAt the same time, many Click users need this functionality.\nYou can read interesting discussions about it in the following issues:\n\n* [issue 257](https://github.com/pallets/click/issues/257)\n* [issue 373](https://github.com/pallets/click/issues/373)\n* [issue 509](https://github.com/pallets/click/issues/509)\n* [issue 1137](https://github.com/pallets/click/issues/1137)\n\nThe aim of this package is to provide group options with extensible functionality\nusing canonical and clean API (Click-like API as far as possible).\n\n## Quickstart\n\n### Installing\n\nInstall and update using pip:\n\n```bash\npip install -U click-option-group\n```\n\n### A Simple Example\n\nHere is a simple example how to use option groups in your Click-based CLI.\nJust use `optgroup` for declaring option groups by decorating\nyour command function in Click-like API style.\n\n```python\n# app.py\n\nimport click\nfrom click_option_group import optgroup, RequiredMutuallyExclusiveOptionGroup\n\n@click.command()\n@optgroup.group('Server configuration',\n                help='The configuration of some server connection')\n@optgroup.option('-h', '--host', default='localhost', help='Server host name')\n@optgroup.option('-p', '--port', type=int, default=8888, help='Server port')\n@optgroup.option('-n', '--attempts', type=int, default=3, help='The number of connection attempts')\n@optgroup.option('-t', '--timeout', type=int, default=30, help='The server response timeout')\n@optgroup.group('Input data sources', cls=RequiredMutuallyExclusiveOptionGroup,\n                help='The sources of the input data')\n@optgroup.option('--tsv-file', type=click.File(), help='CSV/TSV input data file')\n@optgroup.option('--json-file', type=click.File(), help='JSON input data file')\n@click.option('--debug/--no-debug', default=False, help='Debug flag')\ndef cli(**params):\n    print(params)\n\nif __name__ == '__main__':\n    cli()\n```\n\n```bash\n$ python app.py --help\nUsage: app.py [OPTIONS]\n\nOptions:\n  Server configuration:           The configuration of some server connection\n    -h, --host TEXT               Server host name\n    -p, --port INTEGER            Server port\n    -n, --attempts INTEGER        The number of connection attempts\n    -t, --timeout INTEGER         The server response timeout\n  Input data sources: [mutually_exclusive, required]\n                                  The sources of the input data\n    --tsv-file FILENAME           CSV/TSV input data file\n    --json-file FILENAME          JSON input data file\n  --debug / --no-debug            Debug flag\n  --help                          Show this message and exit.\n```\n\n## Documentation\n\nhttps://click-option-group.readthedocs.io\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Option groups missing in Click",
    "version": "0.5.9",
    "project_urls": {
        "Code": "https://github.com/click-contrib/click-option-group",
        "Documentation": "https://click-option-group.readthedocs.io",
        "Homepage": "https://github.com/click-contrib/click-option-group",
        "Issues": "https://github.com/click-contrib/click-option-group/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "754554bb2d8d4138964a94bef6e9afe48b0be4705ba66ac442ae7d8a8dc4ffef",
                "md5": "205ab63957552c54a1821a33c2ef3538",
                "sha256": "ad2599248bd373e2e19bec5407967c3eec1d0d4fc4a5e77b08a0481e75991080"
            },
            "downloads": -1,
            "filename": "click_option_group-0.5.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "205ab63957552c54a1821a33c2ef3538",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 11553,
            "upload_time": "2025-10-09T09:38:00",
            "upload_time_iso_8601": "2025-10-09T09:38:00.066836Z",
            "url": "https://files.pythonhosted.org/packages/75/45/54bb2d8d4138964a94bef6e9afe48b0be4705ba66ac442ae7d8a8dc4ffef/click_option_group-0.5.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "efffd291d66595b30b83d1cb9e314b2c9be7cfc7327d4a0d40a15da2416ea97b",
                "md5": "93038ab84615f17f80f6aedcdfcd02ad",
                "sha256": "f94ed2bc4cf69052e0f29592bd1e771a1789bd7bfc482dd0bc482134aff95823"
            },
            "downloads": -1,
            "filename": "click_option_group-0.5.9.tar.gz",
            "has_sig": false,
            "md5_digest": "93038ab84615f17f80f6aedcdfcd02ad",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 22222,
            "upload_time": "2025-10-09T09:38:01",
            "upload_time_iso_8601": "2025-10-09T09:38:01.474094Z",
            "url": "https://files.pythonhosted.org/packages/ef/ff/d291d66595b30b83d1cb9e314b2c9be7cfc7327d4a0d40a15da2416ea97b/click_option_group-0.5.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-09 09:38:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "click-contrib",
    "github_project": "click-option-group",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "click-option-group"
}
        
Elapsed time: 1.89321s