#!/usr/bin/env python """ To make it work, you need to execute (ie push in .bashrc) complete -o bashdefault -o default -C translate.py blame bash """ import os, sys line = os.environ['COMP_LINE'] cursorpos = int(os.environ['COMP_POINT']) lines = line[:cursorpos].split(" ") first = lines[0] if not first.endswith('translate.py'): sys.exit(0) sys.path.insert(0, os.path.dirname(os.path.abspath(first))) import autopath from pypy.config.config import to_optparse last = lines[-1] was = 'targetpypystandalone.py' in lines if not was and not last.startswith('-'): sys.exit(0) def get_optp(conf): optp = to_optparse(conf) opts = optp.option_list for i in [g.option_list for g in optp.option_groups]: opts += i opt_s = [i.get_opt_string() for i in opts] return opt_s if not was: from pypy.config.translationoption import get_combined_translation_config opt_s = get_optp(get_combined_translation_config()) else: from pypy.config.config import Config, OptionDescription from pypy.config.pypyoption import pypy_optiondescription descr = OptionDescription("pypy", "pypy options", [pypy_optiondescription]) opt_s = get_optp(Config(descr)) to_p = [i for i in opt_s if i.startswith(last)] for i in to_p: print i #d = [config.getkey(path) for path in config.getpaths()]