Refactor exec command to use the ConfiguredProgram abstraction

This PR improves upon the existing implementation of the `exec` command by moving it to its own module and making use of the `ConfiguredProgram` abstraction. It also improves the help text and adds tests for the existing behaviour.