commit 6ab77cb951c927a899ec80d1afde596bb9226fbd Author: Damian Johnson atagar@torproject.org Date: Sat Apr 19 12:03:31 2014 -0700
Moving base autocompletion commands to config
Perfect thing to get out of our source. :) --- stem/interpretor/__init__.py | 6 +++--- stem/interpretor/commands.py | 27 ++++----------------------- stem/interpretor/settings.cfg | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+), 26 deletions(-)
diff --git a/stem/interpretor/__init__.py b/stem/interpretor/__init__.py index 93e4e6a..59c89c8 100644 --- a/stem/interpretor/__init__.py +++ b/stem/interpretor/__init__.py @@ -64,9 +64,9 @@ def main(): sys.exit(1)
with controller: - tab_completer = stem.interpretor.commands.Autocomplete(controller) - readline.parse_and_bind("tab: complete") - readline.set_completer(tab_completer.complete) + autocomplete = stem.interpretor.commands.Autocomplete(controller) + readline.parse_and_bind('tab: complete') + readline.set_completer(autocomplete.complete) readline.set_completer_delims('\n')
interpretor = stem.interpretor.commands.ControlInterpretor(controller) diff --git a/stem/interpretor/commands.py b/stem/interpretor/commands.py index a4ab317..4b35955 100644 --- a/stem/interpretor/commands.py +++ b/stem/interpretor/commands.py @@ -8,33 +8,13 @@ import stem import stem.util.connection import stem.util.tor_tools
-from stem.interpretor import msg +from stem.interpretor import msg, uses_settings from stem.util.term import Attr, Color, format
OUTPUT_FORMAT = (Color.BLUE, ) BOLD_OUTPUT_FORMAT = (Color.BLUE, Attr.BOLD) ERROR_FORMAT = (Attr.BOLD, Color.RED)
-TOR_CONTROLLER_COMMANDS = [ - 'SAVECONF', - 'MAPADDRESS', - 'EXTENDCIRCUIT', - 'SETCIRCUITPURPOSE', - 'SETROUTERPURPOSE', - 'ATTACHSTREAM', - #'+POSTDESCRIPTOR', # TODO: needs multi-line support - 'REDIRECTSTREAM', - 'CLOSESTREAM', - 'CLOSECIRCUIT', - 'QUIT', - 'RESOLVE', - 'PROTOCOLINFO', - #'+LOADCONF', # TODO: needs multi-line support - 'TAKEOWNERSHIP', - 'AUTHCHALLENGE', - 'DROPGUARDS', -] - SIGNAL_DESCRIPTIONS = ( ("RELOAD / HUP", "reload our torrc"), ("SHUTDOWN / INT", "gracefully shut down, waiting 30 seconds if we're a relay"), @@ -73,12 +53,13 @@ HELP_OPTIONS = { }
-def _get_commands(controller): +@uses_settings +def _get_commands(config, controller): """ Provides commands recognized by tor. """
- commands = list(TOR_CONTROLLER_COMMANDS) + commands = config.get('autocomplete', [])
# GETINFO commands
diff --git a/stem/interpretor/settings.cfg b/stem/interpretor/settings.cfg index bb67144..da33dbc 100644 --- a/stem/interpretor/settings.cfg +++ b/stem/interpretor/settings.cfg @@ -171,3 +171,24 @@ help.protocolinfo |starting, like Tor's version and controller authentication. This can be done |before authenticating to the control port.
+# Autocompletion commands. We dynamically load more, such as GETINFO and +# GETCONF options tor will recognize so this just includes other base commands. + +autocomplete SAVECONF +autocomplete MAPADDRESS +autocomplete EXTENDCIRCUIT +autocomplete SETCIRCUITPURPOSE +autocomplete SETROUTERPURPOSE +autocomplete ATTACHSTREAM +#autocomplete +POSTDESCRIPTOR # TODO: needs multi-line support +autocomplete REDIRECTSTREAM +autocomplete CLOSESTREAM +autocomplete CLOSECIRCUIT +autocomplete QUIT +autocomplete RESOLVE +autocomplete PROTOCOLINFO +#autocomplete +LOADCONF # TODO: needs multi-line support +autocomplete TAKEOWNERSHIP +autocomplete AUTHCHALLENGE +autocomplete DROPGUARDS +
tor-commits@lists.torproject.org