I am looking for a generic command line solution that would allow me to add or modify a configuration option inside a config file (ini like format).
Most linux configur
Augeas / augtool aims to do this, although you'll need the right lens for the type of file you're after (you can also write your own), for example, the Nginx lens.
It also has an API if required.