The ``Path`` type is similar to the :class:`File` type, but returns the filename instead of an open file. Various checks can be enabled to validate the type of file and permissions. :param exists: The file or directory needs to exist for the value to be valid. If this is not set to ``True``, and the file does not exist, then all further checks are silently skipped. :param file_okay: Allow a file as a value. :param dir_okay: Allow a directory as a value. :param readable: if true, a readable check is performed. :param writable: if true, a writable check is performed. :param executable: if true, an executable check is performed. :param resolve_path: Make the value absolute and resolve any symlinks. A ``~`` is not expanded, as this is supposed to be done by the shell only. :param allow_dash: Allow a single dash as a value, which indicates a standard stream (but does not open it). Use :func:`~click.open_file` to handle opening this value. :param path_type: Convert the incoming path value to this type. If ``None``, keep Python's default, which is ``str``. Useful to convert to :class:`pathlib.Path`. .. versionchanged:: 8.1 Added the ``executable`` parameter. .. versionchanged:: 8.0 Allow passing ``type=pathlib.Path``. .. versionchanged:: 6.0 Added the ``allow_dash`` parameter.
Method | __init__ |
Undocumented |
Method | coerce |
Undocumented |
Method | convert |
Convert the value to the correct type. This is not called if the value is ``None`` (the missing value). |
Method | shell |
Return a special completion marker that tells the completion system to use the shell to provide path completions for only directories or any paths. |
Method | to |
Gather information that could be useful for a tool generating user-facing documentation. |
Instance Variable | allow |
Undocumented |
Instance Variable | dir |
Undocumented |
Instance Variable | executable |
Undocumented |
Instance Variable | exists |
Undocumented |
Instance Variable | file |
Undocumented |
Instance Variable | name |
Undocumented |
Instance Variable | readable |
Undocumented |
Instance Variable | resolve |
Undocumented |
Instance Variable | type |
Undocumented |
Instance Variable | writable |
Undocumented |
Inherited from ParamType
:
Method | __call__ |
Undocumented |
Method | fail |
Helper method to fail with an invalid value message. |
Method | get |
Returns the metavar default for this param if it provides one. |
Method | get |
Optionally might return extra information about a missing parameter. |
Method | split |
Given a value from an environment variable this splits it up into small chunks depending on the defined envvar list splitter. |
Class Variable | arity |
Undocumented |
Class Variable | envvar |
Undocumented |
Class Variable | is |
Undocumented |
click.types.ParamType.convert
Convert the value to the correct type. This is not called if the value is ``None`` (the missing value). This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types. The ``param`` and ``ctx`` arguments may be ``None`` in certain situations, such as when converting prompt input. If the value cannot be converted, call :meth:`fail` with a descriptive message. :param value: The value to convert. :param param: The parameter that is using this type to convert its value. May be ``None``. :param ctx: The current context that arrived at this value. May be ``None``.
Parameters | |
value:t.Any | Undocumented |
param:t.Optional[ | Undocumented |
ctx:t.Optional[ | Undocumented |
Returns | |
t.Any | Undocumented |
click.types.ParamType.shell_complete
Return a special completion marker that tells the completion system to use the shell to provide path completions for only directories or any paths. :param ctx: Invocation context for this command. :param param: The parameter that is requesting completion. :param incomplete: Value being completed. May be empty. .. versionadded:: 8.0
Parameters | |
ctx:Context | Undocumented |
param:Parameter | Undocumented |
incomplete:str | Undocumented |
Returns | |
t.List[ | Undocumented |