__init__.py
This file
Path
src/click/__init__.py
123 lines · 4.4 KiB · Python
Last changed by
Move `--help` option defaults from its class to its decorator (#2840)Rowlando13before adoptionc9f7d9d
History of this fileTake it
1"""2Click is a simple Python module inspired by the stdlib optparse to make3writing command line scripts fun. Unlike other modules, it's based4around a simple API that does not come with too much magic and is5composable.6"""78from __future__ import annotations910from .core import Argument as Argument11from .core import Command as Command12from .core import CommandCollection as CommandCollection13from .core import Context as Context14from .core import Group as Group15from .core import Option as Option16from .core import Parameter as Parameter17from .decorators import argument as argument18from .decorators import command as command19from .decorators import confirmation_option as confirmation_option20from .decorators import group as group21from .decorators import help_option as help_option22from .decorators import make_pass_decorator as make_pass_decorator23from .decorators import option as option24from .decorators import pass_context as pass_context25from .decorators import pass_obj as pass_obj26from .decorators import password_option as password_option27from .decorators import version_option as version_option28from .exceptions import Abort as Abort29from .exceptions import BadArgumentUsage as BadArgumentUsage30from .exceptions import BadOptionUsage as BadOptionUsage31from .exceptions import BadParameter as BadParameter32from .exceptions import ClickException as ClickException33from .exceptions import FileError as FileError34from .exceptions import MissingParameter as MissingParameter35from .exceptions import NoSuchOption as NoSuchOption36from .exceptions import UsageError as UsageError37from .formatting import HelpFormatter as HelpFormatter38from .formatting import wrap_text as wrap_text39from .globals import get_current_context as get_current_context40from .termui import clear as clear41from .termui import confirm as confirm42from .termui import echo_via_pager as echo_via_pager43from .termui import edit as edit44from .termui import getchar as getchar45from .termui import launch as launch46from .termui import pause as pause47from .termui import progressbar as progressbar48from .termui import prompt as prompt49from .termui import secho as secho50from .termui import style as style51from .termui import unstyle as unstyle52from .types import BOOL as BOOL53from .types import Choice as Choice54from .types import DateTime as DateTime55from .types import File as File56from .types import FLOAT as FLOAT57from .types import FloatRange as FloatRange58from .types import INT as INT59from .types import IntRange as IntRange60from .types import ParamType as ParamType61from .types import Path as Path62from .types import STRING as STRING63from .types import Tuple as Tuple64from .types import UNPROCESSED as UNPROCESSED65from .types import UUID as UUID66from .utils import echo as echo67from .utils import format_filename as format_filename68from .utils import get_app_dir as get_app_dir69from .utils import get_binary_stream as get_binary_stream70from .utils import get_text_stream as get_text_stream71from .utils import open_file as open_file727374def __getattr__(name: str) -> object:75 import warnings7677 if name == "BaseCommand":78 from .core import _BaseCommand7980 warnings.warn(81 "'BaseCommand' is deprecated and will be removed in Click 9.0. Use"82 " 'Command' instead.",83 DeprecationWarning,84 stacklevel=2,85 )86 return _BaseCommand8788 if name == "MultiCommand":89 from .core import _MultiCommand9091 warnings.warn(92 "'MultiCommand' is deprecated and will be removed in Click 9.0. Use"93 " 'Group' instead.",94 DeprecationWarning,95 stacklevel=2,96 )97 return _MultiCommand9899 if name == "OptionParser":100 from .parser import _OptionParser101102 warnings.warn(103 "'OptionParser' is deprecated and will be removed in Click 9.0. The"104 " old parser is available in 'optparse'.",105 DeprecationWarning,106 stacklevel=2,107 )108 return _OptionParser109110 if name == "__version__":111 import importlib.metadata112 import warnings113114 warnings.warn(115 "The '__version__' attribute is deprecated and will be removed in"116 " Click 9.1. Use feature detection or"117 " 'importlib.metadata.version(\"click\")' instead.",118 DeprecationWarning,119 stacklevel=2,120 )121 return importlib.metadata.version("click")122123 raise AttributeError(name)