Audacity already does some commandline processing if started from a CLI. To add the features you need would require some pretty complicated C++ programming but is quite doable. See my post on this general topic here:
https://forum.audacityteam.org/t/unattended-command-line-processing/15543/6