Add the ability to specify a function for the command.

Users are now able to specify either a command to execute or a function that returns a command to execute. This is useful if the command to execute is state dependent. Previously, users would have to specify a command that acted as a wrapper.