Contacts.app command line interface
The closest thing to a generic solution is the CLI package contacts by Shane Celis. The source can be found on GitHub, and is also available as a formulae on Homebrew. The homebrew package can be installed using  with the following command:


  brew install contacts



There are other options that may also work for you. Contacts just stores info in a sqlite database so you can access it with the sqlite command. You could create a custom script to accomplish a particular task if you want.

Scott Stevenson had a tool called abtool up that was popular for a while, so you could try searching through the source on GitHub. In particular, since the app by Shane Celis appears unmaintained (while still functioning well), there are some who are building replacements.