Pass the config to plugins on parser modification to allow completion.

main
Olivier Mangin 8 years ago
parent 576d907a78
commit e129398311

@ -14,7 +14,7 @@ class PapersPlugin(object):
name = None name = None
def get_commands(self, subparsers): def get_commands(self, subparsers, conf):
"""Populates the parser with plugins specific command. """Populates the parser with plugins specific command.
Returns iterable of pairs (command name, command function to call). Returns iterable of pairs (command name, command function to call).
""" """

@ -65,7 +65,7 @@ class AliasPlugin(PapersPlugin):
for name, definition in conf['plugins']['alias'].items(): for name, definition in conf['plugins']['alias'].items():
self.aliases.append(Alias.create_alias(name, definition)) self.aliases.append(Alias.create_alias(name, definition))
def update_parser(self, subparsers): def update_parser(self, subparsers, conf):
"""Add subcommand to the provided subparser""" """Add subcommand to the provided subparser"""
for alias in self.aliases: for alias in self.aliases:
alias_parser = alias.parser(subparsers) alias_parser = alias.parser(subparsers)

@ -80,7 +80,7 @@ def execute(raw_args=sys.argv):
# Extend with plugin commands # Extend with plugin commands
plugins.load_plugins(conf, ui) plugins.load_plugins(conf, ui)
for p in plugins.get_plugins().values(): for p in plugins.get_plugins().values():
p.update_parser(subparsers) p.update_parser(subparsers, conf)
# Eventually autocomplete # Eventually autocomplete
autocomplete(parser) autocomplete(parser)

Loading…
Cancel
Save