1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-10 22:34:18 +00:00

Merge pull request #229 from Asteb612/Features/silence

silent action #228
This commit is contained in:
deadc0de
2020-05-08 18:54:27 +02:00
committed by GitHub
2 changed files with 14 additions and 3 deletions

View File

@@ -21,9 +21,11 @@ class Cmd(DictParser):
"""constructor """constructor
@key: action key @key: action key
@action: action string @action: action string
@silent: action silent
""" """
self.key = key self.key = key
self.action = action self.action = action
self.silent = key.startswith('_')
def execute(self, templater=None, debug=False): def execute(self, templater=None, debug=False):
"""execute the command in the shell""" """execute the command in the shell"""
@@ -53,7 +55,10 @@ class Cmd(DictParser):
err += ' with \"{}\"'.format(args) err += ' with \"{}\"'.format(args)
self.log.warn(err) self.log.warn(err)
return False 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: try:
ret = subprocess.call(cmd, shell=True) ret = subprocess.call(cmd, shell=True)
except KeyboardInterrupt: except KeyboardInterrupt:

View File

@@ -65,6 +65,7 @@ actions:
postaction: echo 'post' > ${tmpa}/post postaction: echo 'post' > ${tmpa}/post
postaction2: echo 'post2' > ${tmpa}/post2 postaction2: echo 'post2' > ${tmpa}/post2
nakedaction: echo 'naked' > ${tmpa}/naked nakedaction: echo 'naked' > ${tmpa}/naked
_silentaction: echo 'silent'
config: config:
backup: true backup: true
create: true create: true
@@ -79,6 +80,7 @@ dotfiles:
- nakedaction - nakedaction
- preaction2 - preaction2
- postaction2 - postaction2
- _silentaction
profiles: profiles:
p1: p1:
dotfiles: dotfiles:
@@ -90,7 +92,7 @@ _EOF
echo "test" > ${tmps}/dotfiles/abc echo "test" > ${tmps}/dotfiles/abc
# install # 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 # checks
[ ! -e ${tmpa}/pre ] && exit 1 [ ! -e ${tmpa}/pre ] && exit 1
@@ -102,7 +104,11 @@ grep naked ${tmpa}/naked >/dev/null
[ ! -e ${tmpa}/pre2 ] && exit 1 [ ! -e ${tmpa}/pre2 ] && exit 1
grep pre2 ${tmpa}/pre2 >/dev/null grep pre2 ${tmpa}/pre2 >/dev/null
[ ! -e ${tmpa}/post2 ] && exit 1 [ ! -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 ## CLEANING
rm -rf ${tmps} ${tmpd} ${tmpa} rm -rf ${tmps} ${tmpd} ${tmpa}