def init(self): super(VirtualEnvSupport, self).init() # FIXME: opt_completer is broken self.contribute_completer('virtualenv .*', opt_completer('virtualenv'))
""" smashlib.plugins.fabric documentation: http://mattvonrocketstein.github.io/smash/plugins.html#fabric """ import ast from smashlib.plugins import Plugin from goulash.python import ope from smashlib.completion import opt_completer from smashlib._logging import smash_log, completion_log fabric_opt_completer = opt_completer("fab") def fabric_cmd_completer(self, event): completion_log.info("event [{0}]".format(event.__dict__)) if event.symbol.startswith("-"): return [] if ope("fabfile.py"): _fabfile = "fabfile.py" elif ope("Fabfile.py"): _fabfile = "Fabfile.py" else: smash_log.info("no fabfile was found") return [] with open(_fabfile, "r") as fhandle: src = fhandle.read() node = ast.parse(src) return list([x.name for x in ast.walk(node) if isinstance(x, ast.FunctionDef)]) class FabricPlugin(Plugin):
This code adds tab completion over tox CLI options, and dynamic determination of environments for "tox -e" """ import os from smashlib import get_smash from smashlib.plugins import Plugin from smashlib.util._tox import get_tox_envs from smashlib.completion import opt_completer def setup_completer(self, event): return 'install develop build'.split() tox_completer = opt_completer('tox') def tox_env_completer(self, event): """ """ line = event.line if line and line.split()[-1].strip().endswith('-e'): return get_tox_envs() class ToxPlugin(Plugin): def install(self): self.smash.add_completer(tox_env_completer, re_key='tox .*-e') self.smash.add_completer(tox_completer, re_key='tox .*') return self