lucc / khard

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

Please add automerge feature #248

Closed aelmahmoudy closed 4 years ago

aelmahmoudy commented 4 years ago

Please add automerge feature that would scan the whole address book and merge possibly duplicate contacts, that would be detected, if the contacts have similar name,address, phone or email.

My suggestion is that when khard finds possibly duplicate contacts, it would prompt the user whether to merge those contacts.

lucc commented 4 years ago

I am very sceptical about such a feature. It sounds like a lot of work if you want to get it right in most cases and at the same time sounds like a feature that is rarely needed.

Recently we merged #246 which adds the -F option. With it you can output selected fields. You could use that and try to write a simple script:

khard ls -F name,email,uid -p

That is tab separated output. You can do any processing in python or perl or whatever to find and then use the uids to generate your merge commands: khard merge -u FROM_UID -U TO_UID. If you want a stronger output format from khard you can use khard show --format=yaml which can display one contact as a yaml document. You could also use that for further processing.

If you would want to write such a feature as a subcommand to khard, the most important part is what I mentioned in the middle as "do any processing ... to find the uids". You would at least need

  1. a decision which fields to inspect
  2. an algorithm to decide what is "similar"
  3. proper handling of edge cases (empty fields, three or more similar contacts, ...)
aelmahmoudy commented 4 years ago

Thanks for the suggestion, is this merge request applicable to khard 0.15.1 ?

lucc commented 4 years ago

246 is not in any release yet (only the develop branch), it will be in the next release.

lucc commented 4 years ago

The mentioned PR is in v0.16.

I will close this as "won't fix".