diff --git a/server/eit/commands/lock.py b/server/eit/commands/lock.py index 13cbfe19f..bb50ffc87 100644 --- a/server/eit/commands/lock.py +++ b/server/eit/commands/lock.py @@ -62,6 +62,39 @@ class EitLock(EitCommand): return parser + def bashcomp(self, last_arg): + """ + Overridden from EitCommand + """ + import sys + + entropy_server = self._entropy(handle_uninitialized=False, + installed_repo=-1) + outcome = entropy_server.repositories() + for arg in self._args: + if arg in outcome: + # already given a repo + return + outcome += ["--client", "--status"] + + def _startswith(string): + if last_arg is not None: + if last_arg not in outcome: + return string.startswith(last_arg) + return True + + if self._args: + # only filter out if last_arg is actually + # something after this.NAME. + outcome = sorted(filter(_startswith, outcome)) + + for arg in self._args: + if arg in outcome: + outcome.remove(arg) + + sys.stdout.write(" ".join(outcome) + "\n") + sys.stdout.flush() + def parse(self): parser = self._get_parser() try: