def __init__(self): self.config = self.getConfig('~/.mycloudbackup') self.serviceTypes = utils.getAllServices() self.services = self.config.getServices() self.outputTypes = utils.getAllOutputs() self.outputs = self.config.getOutputs() logging.basicConfig(level=logging.DEBUG)
def getParser(self): parser = argparse.ArgumentParser() parser.add_argument('--config', default='~/.mycloudbackup', help="Config file to use") parser.add_argument('-v', '--verbose', action='store_true') subparsers = parser.add_subparsers(title='commands') ############# # add-service ############# addService = subparsers.add_parser('add-service', help='Add a new service to be backed up' ) help = "Type of the service, available: " help += '[' + '|'.join(utils.getAllServices().keys()) addService.add_argument('--type', help=help) addService.set_defaults(func=self.addServiceCmd) ############# # add-output ############# addOutput = subparsers.add_parser('add-output', help='Add a new output' ) help = "Type of the output, available: " help += '[' + '|'.join(utils.getAllOutputs().keys()) addOutput.add_argument('--type', help=help) addOutput.set_defaults(func=self.addOutputCmd) ############# # RUN ############# run = subparsers.add_parser('run', help='Run the backups' ) help = "Backup mode: [mirror, full]" run.add_argument('--mode', help=help) run.set_defaults(func=self.runCmd) return parser