From: Fred Date: Sat, 18 May 2013 10:26:30 +0000 (+0800) Subject: Easier to filter the checks to perform X-Git-Tag: v0.4~11 X-Git-Url: https://git.cameron1729.xyz/?a=commitdiff_plain;h=7e82bd47d2f54fb4f9024811f80b97cac7c06726;p=mdk.git Easier to filter the checks to perform --- diff --git a/extra/bash_completion b/extra/bash_completion index c02e95e..3131bed 100644 --- a/extra/bash_completion +++ b/extra/bash_completion @@ -85,7 +85,7 @@ function _moodle() { fi ;; check) - # Empty options. + OPTS="--all --branch --cached --directories --remotes --wwwroot" ;; config) if [[ "${COMP_CWORD}" == 2 ]]; then diff --git a/lib/commands/check.py b/lib/commands/check.py index 2f07401..a77f860 100644 --- a/lib/commands/check.py +++ b/lib/commands/check.py @@ -37,36 +37,87 @@ class CheckCommand(Command): 'action': 'store_true', 'help': 'Automatically fix all the identified problems' } + ), + ( + ['--all'], + { + 'action': 'store_true', + 'help': 'Enable all the checks, this is the default' + } + ), + ( + ['--branch'], + { + 'action': 'store_true', + 'help': 'Check the branch checked out on your integration instances' + } ), ( - ['--limit', '-l'], + ['--cached'], { - 'nargs': '*', - 'default': ['branch', 'cached', 'directories', 'remotes', 'wwwroot'], - 'choices': ['branch', 'cached', 'directories', 'remotes', 'wwwroot'], - 'help': 'Limit the identification and fix to those type of issues' + 'action': 'store_true', + 'help': 'Check the cached repositories' } + + ), + ( + ['--directories'], + { + 'action': 'store_true', + 'help': 'Check the directories set in the config file' + } + + ), + ( + ['--remotes'], + { + 'action': 'store_true', + 'help': 'Check the remotes of your instances' + } + + ), + ( + ['--wwwroot'], + { + 'action': 'store_true', + 'help': 'Check the $CFG->wwwroot of your instances' + } + ) ] _description = 'Perform several checks on your current installation' def run(self, args): + allChecks = True + if not args.all: + argsDict = vars(args) + commands = ['directories', 'cached', 'remotes', 'wwwroot', 'branch'] + for i in commands: + if argsDict.get(i): + allChecks = False + break + # Check directories - 'directories' in args.limit and self.directories(args) + if args.directories or allChecks: + self.directories(args) # Check the cached remotes - 'cached' in args.limit and self.cachedRepositories(args) + if args.cached or allChecks: + self.cachedRepositories(args) # Check instances remotes - 'remotes' in args.limit and self.remotes(args) + if args.remotes or allChecks: + self.remotes(args) # Check instances wwwroot - 'wwwroot' in args.limit and self.wwwroot(args) + if args.wwwroot or allChecks: + self.wwwroot(args) # Check the branches - 'branch' in args.limit and self.branch(args) + if args.branch or allChecks: + self.branch(args) def branch(self, args): """Make sure the correct branch is checked out. Only on integration branches."""