diff --git a/dotdrop/action.py b/dotdrop/action.py index 0123051..ccac7ba 100644 --- a/dotdrop/action.py +++ b/dotdrop/action.py @@ -21,9 +21,11 @@ class Cmd(DictParser): """constructor @key: action key @action: action string + @silent: action silent """ self.key = key self.action = action + self.silent = key.startswith('_') def execute(self, templater=None, debug=False): """execute the command in the shell""" @@ -53,7 +55,10 @@ class Cmd(DictParser): err += ' with \"{}\"'.format(args) self.log.warn(err) return False - self.log.sub('executing \"{}\"'.format(cmd)) + if self.silent: + self.log.sub('executing silent action \"{}\"'.format(self.key)) + else: + self.log.sub('executing \"{}\"'.format(cmd)) try: ret = subprocess.call(cmd, shell=True) except KeyboardInterrupt: diff --git a/tests-ng/actions.sh b/tests-ng/actions.sh index 3087ed7..c4e40f9 100755 --- a/tests-ng/actions.sh +++ b/tests-ng/actions.sh @@ -65,6 +65,7 @@ actions: postaction: echo 'post' > ${tmpa}/post postaction2: echo 'post2' > ${tmpa}/post2 nakedaction: echo 'naked' > ${tmpa}/naked + _silentaction: echo 'silent' config: backup: true create: true @@ -79,6 +80,7 @@ dotfiles: - nakedaction - preaction2 - postaction2 + - _silentaction profiles: p1: dotfiles: @@ -90,7 +92,7 @@ _EOF echo "test" > ${tmps}/dotfiles/abc # install -cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V +cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V 2>&1 | tee ${tmpa}/log # checks [ ! -e ${tmpa}/pre ] && exit 1 @@ -102,7 +104,11 @@ grep naked ${tmpa}/naked >/dev/null [ ! -e ${tmpa}/pre2 ] && exit 1 grep pre2 ${tmpa}/pre2 >/dev/null [ ! -e ${tmpa}/post2 ] && exit 1 -grep post2 ${tmpa}/post2 >/dev/null +grep post ${tmpa}/post2 >/dev/null +[ ! -e ${tmpa}/log ] && exit 1 +grep "executing \"echo 'naked' > ${tmpa}/naked" ${tmpa}/log >/dev/null +grep "executing \"echo 'silent'" ${tmpa}/log >/dev/null && false +grep "executing silent action \"_silentaction\"" ${tmpa}/log >/dev/null ## CLEANING rm -rf ${tmps} ${tmpd} ${tmpa}