khard
khard copied to clipboard
Custom address templates
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.
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.
For users who are interested in scripting a custom post address format themselfs you can try one of these ways:
- Use
khard list --fields "...." --parsable
to generate output suitable for further processing with awk or so. This prints multible contacts. - 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.