def complete(self, ctx, incomplete): # got from click.termui.style if "," not in incomplete and ":" not in incomplete: candidates = self.colors + [key + "-" for key in self.args.keys()] candidates = [ candidate for candidate in candidates if startswith(candidate, incomplete) ] if len(candidates) == 1: incomplete = candidates[0] tested = incomplete prefix = "" valuematch = re.match( "^(?P<prefix>.*?)(?P<key>[^,:]+)-(?P<value>[^,]*)$", incomplete) keymatch = re.match("^(?P<prefix>.*?),(?P<key>[^,:]*)$", incomplete) if valuematch: prefix, key, value = valuematch.groups() candidates = self.args.get(key, []) tested = value or "" prefix = "{}{}-".format(prefix, key) elif keymatch: prefix, key = keymatch.groups() candidates = [key_ + "-" for key_ in self.args.keys()] tested = key prefix = "{},".format(prefix) return [ prefix + str(candidate) for candidate in candidates if startswith(str(candidate), tested) ]
def complete(self, ctx, incomplete): return [ user["name"] for user in config.slack.users.values() if startswith(user.name, incomplete) or (user.email and startswith(user.email, incomplete)) or startswith(user["real_name"], incomplete) or startswith(user["display_name"], incomplete) ]
def complete(self, ctx, incomplete): @cache_disk(expire=600) def get_candidates(parent_path): if parent_path != config.main_command.path: candidates = [ (parent_path + "." + cmd, (get_command_safe(parent_path + "." + cmd).short_help if get_command_safe(parent_path + "." + cmd) is not None else "Broken command")) for cmd in list_commands(parent_path) ] else: candidates = [ (cmd, (get_command_safe(cmd).short_help if get_command_safe(cmd) is not None else "Broken command")) for cmd in list_commands(config.main_command.path) ] + [(config.main_command.path, "Main parameters")] period_candidates = [ (elem[0] + ".", None) for elem in candidates if isinstance(get_command_safe(elem[0]), Group) ] candidates += period_candidates return candidates if "." in incomplete: split = incomplete.split(".") parent_path = ".".join(split[:-1]) else: parent_path = config.main_command.path candidates = get_candidates(parent_path) return [(cmd, cmd_help) for cmd, cmd_help in candidates if startswith(cmd, incomplete) and ( self.recursive or "." not in cmd)]
def complete(self, ctx, incomplete): completion = set() for path in self.path(ctx): for file in os.listdir(path): if startswith(file, incomplete): completion.add(file) return completion
def complete(self, ctx, incomplete): @cache_disk(expire=3600) def _list_rest(*args, **kwargs): return self.list(*args, **kwargs) url = re.sub('[^/]+$', '', incomplete) res = [(u, ' '.join(p)) for u, p in _list_rest(url, True, False) if startswith(u, incomplete)] res += [(s[0] + '/', None) for s in res] return res
def complete(self, ctx, incomplete): choices = [ " ".join([quote(v) for v in value]) for value in config.settings.get("launchers", {}).values() ] return [ launcher for launcher in choices if startswith(launcher, incomplete) ]
def complete(self, ctx, incomplete): @cache_disk(expire=600) def get_shortdoc(path): cmd = get_command_safe(path) if cmd is None: return "Broken command" else: return cmd.short_help choices = [(path, get_shortdoc(path)) for path in self.settings(ctx).keys()] return [(cmd, cmd_help) for cmd, cmd_help in choices if startswith(cmd, incomplete)]
def complete(self, ctx, incomplete): return [clr for clr in git_remotes() if startswith(clr, incomplete)]
def complete(self, ctx, incomplete): choice = self.getchoice(ctx) return [(plugin, load_short_help(plugin)) for plugin in choice if startswith(plugin, incomplete)]
def complete(self, ctx, incomplete): choices = config.settings.get("launchers", {}).keys() return [ launcher for launcher in choices if startswith(launcher, incomplete) ]
def complete(self, ctx, incomplete): return [ candidate for candidate in self.choices if startswith(candidate, incomplete) ]
def complete(self, ctx, incomplete): return [ name for name in self.choices() if startswith(name, incomplete) ]
def complete(self, ctx, incomplete): return (choice for choice in self.choices if startswith(choice, incomplete))
def complete(self, ctx, incomplete): if _remote: return [clr for clr in self.refs if startswith(clr, incomplete)] else: return []
def complete(self, ctx, incomplete): return [clr for clr in self.refs if startswith(clr, incomplete)]
def complete(self, ctx, incomplete): return [ c.name for c in config.slack.conversations.values() if startswith(c.name, incomplete) ]
def complete(self, ctx, incomplete): choice = self.getchoice(ctx) return [(recipe, load_short_help(recipe)) for recipe in choice if startswith(recipe, incomplete)]