git-credential-keepassxc icon indicating copy to clipboard operation
git-credential-keepassxc copied to clipboard

Support for error codes

Open KaiJan57 opened this issue 3 years ago • 2 comments

As far as I can tell, git-credential-keepassxc always returns error 0 or 1, regardless of what exactly went wrong. For scriptiing purposes it would be really cool if e.g. no unlocked database was indicated by a different error code from no entry found errors, such that the script can take proper action… I'm not very fluent in rust, but I think it should be really easy to implement for great value, isn't it? :)

KaiJan57 avatar Jul 04 '22 19:07 KaiJan57

It's actually not that easy... I use https://github.com/dtolnay/anyhow for error handling which is specifically designed for use cases such as CLI tools, where you don't care about what went wrong, just care about whether it went wrong.

Is there a particular use case you can't work around without this atm? Or is this more of a 'nice to have' you have in mind?

Frederick888 avatar Jul 05 '22 09:07 Frederick888

Okay so my issue is kind of an XY type: I want to make sure that the database is unlocked when I retrieve passwords from within isync I use for my email, so my sync script would need to detect that the failure was caused by the fact that no database is unlocked, and that would enable it to not start isync in the first place (I dont want it to run with locked database because it wastes resources and creates a pop up for each failed login, prompting me to type in the password). In the end I worked around this issue by creating a test entry that is guaranteed to be available, so if that request fails, my script knows that the database is locked and it does not invoke isync. I know, if it really is that bad to implement, I think we might consider this issue a 'nice to have' and focus on other matters (close this issue if you think alike), but if you find a good opportunity to implement different error codes, I would be happy to avoid that dirty hack ;) Anyhow, thanks for considering my request and have a nice day :)

KaiJan57 avatar Jul 06 '22 16:07 KaiJan57