| 332 | |
| 333 | |
| 334 | def get_password_from_file(password_file: str | None) -> str | None: |
| 335 | if not password_file: |
| 336 | return None |
| 337 | try: |
| 338 | with open(password_file) as fp: |
| 339 | return fp.readline().removesuffix('\n') |
| 340 | except FileNotFoundError: |
| 341 | click.secho(f"Password file '{password_file}' not found", err=True, fg='red') |
| 342 | sys.exit(1) |
| 343 | except PermissionError: |
| 344 | click.secho(f"Permission denied reading password file '{password_file}'", err=True, fg='red') |
| 345 | sys.exit(1) |
| 346 | except IsADirectoryError: |
| 347 | click.secho(f"Path '{password_file}' is a directory, not a file", err=True, fg='red') |
| 348 | sys.exit(1) |
| 349 | except Exception as e: |
| 350 | click.secho(f"Error reading password file '{password_file}': {str(e)}", err=True, fg='red') |
| 351 | sys.exit(1) |
| 352 | |
| 353 | |
| 354 | def preprocess_cli_args( |