summaryrefslogtreecommitdiff
path: root/dotbot/plugins/shell.py
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2020-11-15 16:25:57 +0100
committerAnton Khirnov <anton@khirnov.net>2020-11-15 16:25:57 +0100
commit79c9c0747e876c0b97a4fb3fe91fa9825e462722 (patch)
treeff298dd32dfccfde9921d0ac2c48bc36113a55c6 /dotbot/plugins/shell.py
parent5ffd208bdb85215cc7c5ba6f2903bfa7756aa945 (diff)
Add a dry run mode.
Diffstat (limited to 'dotbot/plugins/shell.py')
-rw-r--r--dotbot/plugins/shell.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/dotbot/plugins/shell.py b/dotbot/plugins/shell.py
index f0121e6..75d4dca 100644
--- a/dotbot/plugins/shell.py
+++ b/dotbot/plugins/shell.py
@@ -11,7 +11,7 @@ class Shell(dotbot.Plugin):
_directive = 'shell'
- def handle(self, directive, data):
+ def handle(self, directive, data, dry_run):
success = True
defaults = self._context.defaults().get('shell', {})
for item in data:
@@ -38,6 +38,10 @@ class Shell(dotbot.Plugin):
self._log.info('%s' % msg)
else:
self._log.info('%s [%s]' % (msg, cmd))
+
+ if dry_run:
+ continue
+
ret = dotbot.util.shell_command(
cmd,
cwd=self._context.base_directory(),
@@ -48,8 +52,13 @@ class Shell(dotbot.Plugin):
if ret != 0:
success = False
self._log.warning('Command [%s] failed' % cmd)
- if success:
+
+ if dry_run:
+ self._log.verbose('shell/dry run: commands not executed')
+ success = False
+ elif success:
self._log.verbose('All commands have been executed')
else:
self._log.error('Some commands were not successfully executed')
+
return success