Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Bug Fixes
* Fix spelling of `ssl-verify-server-cert` option.
* Improve handling of `ssl-verify-server-cert` False values.
* Guard against missing contributors file on startup.
* Friendlier errors on password-file failures.


Internal
Expand Down
16 changes: 8 additions & 8 deletions mycli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@
DEFAULT_HEIGHT = 25


class PasswordFileError(Exception):
"""Base exception for errors related to reading password files."""


class MyCli:
default_prompt = "\\t \\u@\\h:\\d> "
default_prompt_splitln = "\\u@\\h\\n(\\t):\\d>"
Expand Down Expand Up @@ -561,13 +557,17 @@ def get_password_from_file(self, password_file: str) -> str:
password = fp.readline().strip()
return password
except FileNotFoundError:
raise PasswordFileError(f"Password file '{password_file}' not found") from None
click.secho(f"Password file '{password_file}' not found", err=True, fg="red")
sys.exit(1)
except PermissionError:
raise PasswordFileError(f"Permission denied reading password file '{password_file}'") from None
click.secho(f"Permission denied reading password file '{password_file}'", err=True, fg="red")
sys.exit(1)
except IsADirectoryError:
raise PasswordFileError(f"Path '{password_file}' is a directory, not a file") from None
click.secho(f"Path '{password_file}' is a directory, not a file", err=True, fg="red")
sys.exit(1)
except Exception as e:
raise PasswordFileError(f"Error reading password file '{password_file}': {str(e)}") from None
click.secho(f"Error reading password file '{password_file}': {str(e)}", err=True, fg="red")
sys.exit(1)

def handle_editor_command(self, text: str) -> str:
r"""Editor command is any query that is prefixed or suffixed by a '\e'.
Expand Down