File: index.rst

package info (click to toggle)
python-click-option-group 0.5.6-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 252 kB
  • sloc: python: 1,141; makefile: 16
file content (80 lines) | stat: -rw-r--r-- 2,421 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
.. click-option-group documentation master file, created by
   sphinx-quickstart on Sat Jan 18 02:32:05 2020.
   You can adapt this file completely to your liking, but it should at least
   contain the root `toctree` directive.

click-option-group
==================

**click-option-group** is a `Click <https://click.palletsprojects.com>`_-extension package
that adds option groups missing in 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).

Installing
----------

You can install and update click-option-group using pip::

   pip install -U click-option-group

Quickstart
----------

Here is a simple example how to use option groups in your Click-based CLI.

.. code-block:: python

    import click
    from click_option_group import optgroup

    @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')
    @click.option('--debug/--no-debug', default=False, help='Debug flag')
    def cli(host, port, debug):
         print(params)

    if __name__ == '__main__':
        cli()


Contents
--------

.. toctree::
   :maxdepth: 2

   tutorial
   api
   changelog


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`