Skip to content

click_config

A configuration option for click.

Classes

ConfigOption

ConfigOption(param_decls: Optional[StrSequence] = None, show_default: Optional[BoolOrStr] = None, allow_from_autoenv: bool = True, help: Optional[str] = None, show_envvar: bool = False, **attrs)

Bases: Option

A configuration option for click.

Methods:

process_value
process_value(ctx: Context, value: Any) -> Optional[Path]

Process the value of the option.

Functions:

config_option

config_option(*param_decls: str, cls: Optional[Type[ConfigOption]] = None, **attrs: Any) -> Callable[[FC], FC]

Attaches a ConfigOption to the command.

All positional arguments are passed as parameter declarations to ConfigOption.

All keyword arguments are forwarded unchanged (except cls). This is equivalent to creating a ConfigOption instance manually and attaching it to the Command.params list.

For the default option class, refer to ConfigOption and Parameter for descriptions of parameters.

PARAMETER DESCRIPTION
*param_decls

Passed as positional arguments to the constructor of cls.

TYPE: str DEFAULT: ()

cls

the option class to instantiate. This defaults to ConfigOption.

TYPE: Optional[Type[ConfigOption]] DEFAULT: None

**attrs

Passed as keyword arguments to the constructor of cls.

TYPE: Any DEFAULT: {}

RETURNS DESCRIPTION
Callable[[FC], FC]

A decorated function.

download_url

download_url(url: str) -> Path

Download the contents of a URL.

PARAMETER DESCRIPTION
url

The URL to download

TYPE: str

RETURNS DESCRIPTION
Path

The Path to the downloaded file.

RAISES DESCRIPTION
BadInputError

if there is a problem downloading the URL

get_file_name_from_url

get_file_name_from_url(url: str) -> str

Extracts the file name from a URL.

PARAMETER DESCRIPTION
url

The URL to extract the file name from.

TYPE: str

RETURNS DESCRIPTION
str

The file name from the URL, or an empty string if there is no file name.

resolve_conf_location

resolve_conf_location(url_or_path: str) -> Path

Resolve a URL or path.

The path is considered a URL if it is parseable as such and starts with http:// or https://.

PARAMETER DESCRIPTION
url_or_path

The URL or path to resolve.

TYPE: str

RETURNS DESCRIPTION
Path

The contents of the location.

RAISES DESCRIPTION
BumpVersionError

if the file does not exist.