diff options
author | Anish Athalye <me@anishathalye.com> | 2020-03-25 21:38:39 -0400 |
---|---|---|
committer | Anish Athalye <me@anishathalye.com> | 2020-03-26 11:23:07 -0400 |
commit | 7ffaa65482a59fa485e7a8f19fe07a33694fc157 (patch) | |
tree | 78e5990b5934b920b797fe7bace046b3b9bf51c6 /dotbot/dispatcher.py | |
parent | 5d83f9e797b1950199e127a8196803f5e33e0916 (diff) |
Add --only and --except command-line arguments
Internal to Dotbot, we use the name "skip" instead of "except", because
the latter is a keyword, and using a name like "except_" didn't seem as
nice.
Diffstat (limited to 'dotbot/dispatcher.py')
-rw-r--r-- | dotbot/dispatcher.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/dotbot/dispatcher.py b/dotbot/dispatcher.py index 36eac02..10e4293 100644 --- a/dotbot/dispatcher.py +++ b/dotbot/dispatcher.py @@ -4,10 +4,12 @@ from .messenger import Messenger from .context import Context class Dispatcher(object): - def __init__(self, base_directory): + def __init__(self, base_directory, only=None, skip=None): self._log = Messenger() self._setup_context(base_directory) self._load_plugins() + self._only = only + self._skip = skip def _setup_context(self, base_directory): path = os.path.abspath( @@ -20,6 +22,10 @@ class Dispatcher(object): success = True for task in tasks: for action in task: + if self._only is not None and action not in self._only \ + or self._skip is not None and action in self._skip: + self._log.info('Skipping action %s' % action) + continue handled = False if action == 'defaults': self._context.set_defaults(task[action]) # replace, not update |