Skip to content

Commit 68ac18b

Browse files
committed
Add force_option and no_pager_option to "options" module.
1 parent 8cd9367 commit 68ac18b

File tree

1 file changed

+45
-6
lines changed

1 file changed

+45
-6
lines changed

consolekit/options.py

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@
3838
__all__ = ["verbose_option", "version_option", "colour_option"]
3939

4040

41-
def verbose_option(help: str = "Show verbose output.") -> Callable:
41+
def verbose_option(help_text: str = "Show verbose output.") -> Callable:
4242
"""
4343
Adds an option (via the parameter ``verbose``: :class:`int`) to enable verbose output.
4444
4545
The option can be provided multiple times by the user.
4646
47-
:param help: The help text for the option.
47+
:param help_text: The help text for the option.
4848
4949
:rtype:
5050
@@ -55,7 +55,7 @@ def verbose_option(help: str = "Show verbose output.") -> Callable:
5555
"-v",
5656
"--verbose",
5757
count=True,
58-
help=help,
58+
help=help_text,
5959
)
6060

6161

@@ -82,11 +82,11 @@ def version_option(callback: Callable[[Context, Option, int], Any]) -> Callable:
8282
)
8383

8484

85-
def colour_option(help="Whether to use coloured output.") -> Callable:
85+
def colour_option(help_text="Whether to use coloured output.") -> Callable:
8686
"""
8787
Adds an option (via the parameter ``colour``: :class:`bool`) to enable verbose output.
8888
89-
:param help: The help text for the option.
89+
:param help_text: The help text for the option.
9090
9191
:rtype:
9292
@@ -97,5 +97,44 @@ def colour_option(help="Whether to use coloured output.") -> Callable:
9797
"--colour/--no-colour",
9898
is_flag=True,
9999
default=None,
100-
help=help,
100+
help=help_text,
101+
)
102+
103+
104+
def force_option(help_text: str) -> Callable:
105+
"""
106+
Decorator to add the ``-f / --force`` option to a click command.
107+
108+
:param help_text: The help text for the option.
109+
110+
:rtype:
111+
112+
.. versionadded:: 0.5.0
113+
"""
114+
115+
return click.option(
116+
"-f",
117+
"--force",
118+
is_flag=True,
119+
default=False,
120+
help=help_text,
121+
)
122+
123+
124+
def no_pager_option(help_text="Disable the output pager.") -> Callable:
125+
"""
126+
Decorator to add the ``--no-pager`` option to a click command.
127+
128+
:param help_text: The help text for the option.
129+
130+
:rtype:
131+
132+
.. versionadded:: 0.5.0
133+
"""
134+
135+
return click.option(
136+
"--no-pager",
137+
is_flag=True,
138+
default=False,
139+
help=help_text,
101140
)

0 commit comments

Comments
 (0)