diff --git a/dotbot/cli.py b/dotbot/cli.py index 32db016..1a986f5 100644 --- a/dotbot/cli.py +++ b/dotbot/cli.py @@ -97,7 +97,7 @@ def main(): # default to directory of config file base_directory = os.path.dirname(os.path.abspath(options.config_file)) os.chdir(base_directory) - dispatcher = Dispatcher(base_directory, only=options.only, skip=options.skip) + dispatcher = Dispatcher(base_directory, only=options.only, skip=options.skip, options=options) success = dispatcher.dispatch(tasks) if success: log.info('\n==> All tasks executed successfully') diff --git a/dotbot/context.py b/dotbot/context.py index 8c42d47..cb2b5df 100644 --- a/dotbot/context.py +++ b/dotbot/context.py @@ -1,14 +1,16 @@ import copy import os +from argparse import Namespace class Context(object): ''' Contextual data and information for plugins. ''' - def __init__(self, base_directory): + def __init__(self, base_directory, options=Namespace()): self._base_directory = base_directory self._defaults = {} + self._options = options pass def set_base_directory(self, base_directory): @@ -25,3 +27,6 @@ class Context(object): def defaults(self): return copy.deepcopy(self._defaults) + + def options(self): + return copy.deepcopy(self._options) diff --git a/dotbot/dispatcher.py b/dotbot/dispatcher.py index 646f6a0..856befa 100644 --- a/dotbot/dispatcher.py +++ b/dotbot/dispatcher.py @@ -1,22 +1,23 @@ import os +from argparse import Namespace from .plugin import Plugin from .messenger import Messenger from .context import Context class Dispatcher(object): - def __init__(self, base_directory, only=None, skip=None): + def __init__(self, base_directory, only=None, skip=None, options=Namespace()): self._log = Messenger() - self._setup_context(base_directory) + self._setup_context(base_directory, options) self._load_plugins() self._only = only self._skip = skip - def _setup_context(self, base_directory): + def _setup_context(self, base_directory, options): path = os.path.abspath( os.path.expanduser(base_directory)) if not os.path.exists(path): raise DispatchError('Nonexistent base directory') - self._context = Context(path) + self._context = Context(path, options) def dispatch(self, tasks): success = True diff --git a/test/tests/plugin.bash b/test/tests/plugin.bash index bdf0c7f..dc2613a 100644 --- a/test/tests/plugin.bash +++ b/test/tests/plugin.bash @@ -1,7 +1,7 @@ test_description='plugin loading works' . '../test-lib.bash' -test_expect_success 'setup' ' +test_expect_success 'setup 1' ' cat > ${DOTFILES}/test.py < ${DOTFILES}/test.py <