From 79c9c0747e876c0b97a4fb3fe91fa9825e462722 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 15 Nov 2020 16:25:57 +0100 Subject: Add a dry run mode. --- dotbot/plugins/shell.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'dotbot/plugins/shell.py') 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 -- cgit v1.2.3