khard icon indicating copy to clipboard operation
khard copied to clipboard

Custom address templates

Open madduck opened this issue 6 years ago • 2 comments

Using the postaladdress command, khard can print an address suitable for printing onto an envelope. But this only really works for some European countries, because the format for post address in most countries of the world differs in that the postal code usually follows city.

It would be great if khard could provide different templates to select from, possibly even make it such that the default template is chosen heuristically by looking at the country subfield.

madduck avatar Feb 05 '19 01:02 madduck

I would say that this is a special case of the ideas in #89 about formatting display names and #179 about formatting the output of listing commands in general. The general solution to all this would be the possibility to provide format strings to make the output controllable by the user. The only issue I always had when thinking about simple date(1) or printf like format strings (but rather in the syntax of pythons str.format()) is the alignment in table like outputs that we have in many places.

lucc avatar Mar 09 '19 10:03 lucc

For users who are interested in scripting a custom post address format themselfs you can try one of these ways:

  1. Use khard list --fields "...." --parsable to generate output suitable for further processing with awk or so. This prints multible contacts.
  2. Use khard show --format=yaml and generate output in yaml format that can be piped to any yaml parser for further processing. For example python + ruamel.yaml. This prints only one contact at a time.

lucc avatar Apr 07 '20 18:04 lucc