niquery.cli.utils module¶
- niquery.cli.utils.force_output(f: Callable) Callable[source]¶
Create a click option to add the
--force / -fflag to a command.Creates a Click command decorator to add an option that can be used to enable or disable the ability to forcefully overwrite existing output files, for example. The value of this option is stored in the Click context object and can be accessed during the command execution.
- Parameters:
f (
Callable) – The function to be wrapped with the Click option.- Returns:
The decorated function with the
--force / -fflag.- Return type:
Callable
- niquery.cli.utils.verify_output_path(path: Path, overwrite: bool = False)[source]¶
Verify whether the output path already exists or is non-empty.
Verifies whether a path exists (if a file) or whether it is not empty (if a directory) it; raise an error if it exists/not empty and
overwriteisFalse.- Parameters:
path (
Path) – Filename.overwrite (
bool) –Trueto allow overwriting the file/writing to a non-empty directory.