File: api.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 (99 lines) | stat: -rw-r--r-- 2,274 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
.. _api:

API Reference
=============

.. currentmodule:: click_option_group

.. autosummary::
    :nosignatures:

    optgroup

    GroupedOption
    OptionGroup

    RequiredAnyOptionGroup
    AllOptionGroup
    RequiredAllOptionGroup
    MutuallyExclusiveOptionGroup
    RequiredMutuallyExclusiveOptionGroup

|

.. py:class:: optgroup

    A global instance of the helper class to manage creating groups and group options via decorators

    The class provides two decorator-methods: ``group``/``__call__`` and ``option``.
    These decorators should be used for adding grouped options. The class have
    single global instance ``optgroup`` that should be used in most cases.

    The example of usage::

        from click_option_group import optgroup

        ...
        @optgroup('Group 1', help='option group 1')
        @optgroup.option('--foo')
        @optgroup.option('--bar')
        @optgroup.group('Group 2', help='option group 2')
        @optgroup.option('--spam')
        ...

    .. py:method:: group(name, *, cls, help, **attrs)

        The decorator creates a new group and collects its options

        Creates the option group and registers all grouped options
        which were added by :func:`option` decorator.

        :param name: Group name or None for deault name
        :param cls: Option group class that should be inherited from :class:`OptionGroup` class
        :param help: Group help or None for empty help
        :param attrs: Additional parameters of option group class

    .. py:method:: option(*param_decls, **attrs)

        The decorator adds a new option to the group

        The decorator is lazy. It adds option decls and attrs.
        All options will be registered by :func:`group` decorator.

        :param param_decls: option declaration tuple
        :param attrs: additional option attributes and parameters

----

.. autoclass:: GroupedOption
    :members:

----

.. autoclass:: OptionGroup
    :members:

----

.. autoclass:: RequiredAnyOptionGroup
    :members:

----

.. autoclass:: AllOptionGroup
    :members:

----

.. autoclass:: RequiredAllOptionGroup
    :members:

----

.. autoclass:: MutuallyExclusiveOptionGroup
    :members:

----

.. autoclass:: RequiredMutuallyExclusiveOptionGroup
    :members: