summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Giarrusso <vito.giarrusso@me.com>2017-07-26 19:03:47 +1000
committerAnish Athalye <me@anishathalye.com>2018-11-21 19:50:32 -0500
commit3bda18ed9c511a926e65b442f3688ff27fa01d9b (patch)
tree5b5b6c0e84f53aa43d987a23943eb666eb3e0901
parentfe9ca6f5ede35d16f28e0c5db781fb39437fd171 (diff)
Add quiet option to shell plugin
-rw-r--r--README.md6
-rw-r--r--plugins/shell.py7
2 files changed, 11 insertions, 2 deletions
diff --git a/README.md b/README.md
index 1d6e938..0e9216c 100644
--- a/README.md
+++ b/README.md
@@ -251,8 +251,9 @@ shell command and the second is an optional human-readable description.
Shell commands support an extended syntax as well, which provides more
fine-grained control. A command can be specified as a dictionary that contains
-the command to be run, a description, and whether `stdin`, `stdout`, and
-`stderr` are enabled. In this syntax, all keys are optional except for the
+the command to be run, a description, whether to suppress outputting the
+command in the display via `quiet`, and whether `stdin`, `stdout`,
+and `stderr` are enabled. In this syntax, all keys are optional except for the
command itself.
#### Example
@@ -266,6 +267,7 @@ command itself.
stdin: true
stdout: true
description: Reading and printing variable
+ quiet: true
-
command: read fail
stderr: true
diff --git a/plugins/shell.py b/plugins/shell.py
index b6f5184..06a9a89 100644
--- a/plugins/shell.py
+++ b/plugins/shell.py
@@ -22,12 +22,15 @@ class Shell(dotbot.Plugin):
with open(os.devnull, 'w') as devnull:
for item in data:
stdin = stdout = stderr = devnull
+ quiet = 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('quiet', False) == True:
+ quiet = True
if isinstance(item, dict):
cmd = item['command']
msg = item.get('description', None)
@@ -37,6 +40,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 'quiet' in item:
+ quiet = True if item['quiet'] == True else False
elif isinstance(item, list):
cmd = item[0]
msg = item[1] if len(item) > 1 else None
@@ -45,6 +50,8 @@ class Shell(dotbot.Plugin):
msg = None
if msg is None:
self._log.lowinfo(cmd)
+ elif quiet:
+ self._log.lowinfo('%s' % msg)
else:
self._log.lowinfo('%s [%s]' % (msg, cmd))
executable = os.environ.get('SHELL')