From a351063b3f65c0cd6f8659cee677f39caf1f5d6f Mon Sep 17 00:00:00 2001 From: Vito Giarrusso Date: Wed, 26 Jul 2017 19:03:47 +1000 Subject: [PATCH] added 'suppressShellCmd' config option to allow only message display --- plugins/shell.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/shell.py b/plugins/shell.py index b6f5184..e0999ed 100644 --- a/plugins/shell.py +++ b/plugins/shell.py @@ -18,16 +18,20 @@ class Shell(dotbot.Plugin): def _process_commands(self, data): success = True + suppress_shell_cmd = False defaults = self._context.defaults().get('shell', {}) with open(os.devnull, 'w') as devnull: for item in data: stdin = stdout = stderr = devnull + suppress_shell_cmd = suppress_shell_cmd = False if defaults.get('stdin', False) == True: stdin = None if defaults.get('stdout', False) == True: stdout = None if defaults.get('stderr', False) == True: stderr = None + if defaults.get('suppressShellCmd', False) == True: + suppress_shell_cmd = True if isinstance(item, dict): cmd = item['command'] msg = item.get('description', None) @@ -37,6 +41,8 @@ class Shell(dotbot.Plugin): stdout = None if item['stdout'] == True else devnull if 'stderr' in item: stderr = None if item['stderr'] == True else devnull + if 'suppressShellCmd' in item: + suppress_shell_cmd = True if item['suppressShellCmd'] == True else False elif isinstance(item, list): cmd = item[0] msg = item[1] if len(item) > 1 else None @@ -46,7 +52,10 @@ class Shell(dotbot.Plugin): if msg is None: self._log.lowinfo(cmd) else: - self._log.lowinfo('%s [%s]' % (msg, cmd)) + if suppress_shell_cmd is False: + self._log.lowinfo('%s [%s]' % (msg, cmd)) + else: + self._log.lowinfo('%s' % (msg)) executable = os.environ.get('SHELL') ret = subprocess.call(cmd, shell=True, stdin=stdin, stdout=stdout, stderr=stderr, cwd=self._context.base_directory(),