Add command line option to specify database

Since command line options are read in the command classes, which fires after the registration of the service provider, I moved the getDatabase part from the service provider to BaseCommand. This led to some restructuring..