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.

Functions

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.

Parameters:

*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:

Callable[[FC], FC]

A decorated function.

download_url

download_url(url: str) -> Path

Download the contents of a URL.

Parameters:

url

The URL to download

TYPE: str

Returns:

Path

The Path to the downloaded file.

Raises:

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.

Parameters:

url

The URL to extract the file name from.

TYPE: str

Returns:

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://.

Parameters:

url_or_path

The URL or path to resolve.

TYPE: str

Raises:

BumpVersionError

if the file does not exist.

Returns:

Path

The contents of the location.