Add members to hostgroup.cfg automatically


Anyone knows a tool or has a program/script that adds a member to a provided group?

This is, I have a hostgroups.cfg file with groups a, b and c.
I want a tool that will take as arguments the name of the member (lets say host1) and the group name (group a) and adds it.

Any help?