Extract common code from command plugins

This extracts the common code from the command plugins and converts them all over to use the module.