class ConfigPlugin (Builtin):
def __init__(self):
super(ConfigPlugin, self).__init__(name='config')
- self._commands = [GetCommand(), SetCommand(), PrintCommand()]
- self._setup_commands()
+ self._commands = [GetCommand(self), SetCommand(self),
+ PrintCommand(self)]
# Define common or complicated arguments
class GetCommand (Command):
"""Get the current value of a configuration option.
"""
- def __init__(self):
+ def __init__(self, plugin):
super(GetCommand, self).__init__(
name='get config',
arguments=[SectionArgument, OptionArgument],
- help=self.__doc__)
+ help=self.__doc__, plugin=plugin)
def _run(self, hooke, inqueue, outqueue, params):
outqueue.put(hooke.config.get(params['section'], params['option']))
noticed by the target classes unless the configuration is reloaded.
This reloading may cause problems in poorly written UIs.
"""
- def __init__(self):
+ def __init__(self, plugin):
super(SetCommand, self).__init__(
name='set config',
arguments=[
name='value', type='string', optional=False,
help='Value to set.'),
],
- help=self.__doc__)
+ help=self.__doc__, plugin=plugin)
def _run(self, hooke, inqueue, outqueue, params):
hooke.config.set(params['section'], params['option'], params['value'])
class PrintCommand (Command):
"""Get the current value of a configuration option.
"""
- def __init__(self):
+ def __init__(self, plugin):
super(PrintCommand, self).__init__(
- name='print config', help=self.__doc__)
+ name='print config', help=self.__doc__, plugin=plugin)
def _run(self, hooke, inqueue, outqueue, params):
out = StringIO()