lucc / khard

Console vcard client
https://khard.readthedocs.io/en/latest/
GNU General Public License v3.0
595 stars 66 forks source link

Use an exception to cancle user interactions #325

Closed lucc closed 11 months ago

lucc commented 11 months ago

Previously None was used as a return value to indicate that the user canceled but since None is also used to indicate the user made "no selection" these were not distinguishable any longer.

Before 9d02824d "q" was handled by calling sys.exit directly.

@jeffa5 the commit 9d02824d was from you. I know this is a very long time ago, but do you remember why you replaced sys.exit with return None in the select() function? https://github.com/lucc/khard/commit/9d02824d418b10ae817350dca442d5bd294b4130#diff-a61de8c4a830ae55b3d7cf5f20bf54f44b71f5684bd73e42094a83246c9fc820L600-R609

To me it looks like a "substitute all" mistake when replacing sys.exit in these places in the same commit: https://github.com/lucc/khard/commit/9d02824d418b10ae817350dca442d5bd294b4130#diff-a61de8c4a830ae55b3d7cf5f20bf54f44b71f5684bd73e42094a83246c9fc820L565-R574 https://github.com/lucc/khard/commit/9d02824d418b10ae817350dca442d5bd294b4130#diff-a61de8c4a830ae55b3d7cf5f20bf54f44b71f5684bd73e42094a83246c9fc820L594-R603 https://github.com/lucc/khard/commit/9d02824d418b10ae817350dca442d5bd294b4130#diff-a61de8c4a830ae55b3d7cf5f20bf54f44b71f5684bd73e42094a83246c9fc820L600-R609

The commit ffbe09d reverts this and throws a custom exception if the user selects "quit". Is there any particular usage scenario where this is not acceptable? I have tried to add more tests for the add-email subcomand but could not find such a use case.