1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-09 00:14:16 +00:00

fix action usage variable expansion

This commit is contained in:
deadc0de6
2019-06-19 16:07:29 +02:00
parent 44723dc032
commit 1888a09ad7
3 changed files with 22 additions and 13 deletions

View File

@@ -86,18 +86,22 @@ class Action(Cmd):
def __repr__(self):
return 'action({})'.format(self.__str__())
def execute(self, templater=None):
def execute(self, templater=None, debug=False):
"""execute the action in the shell"""
ret = 1
action = self.action
if templater:
action = templater.generate_string(self.action)
if debug:
self.log.dbg('action \"{}\" -> \"{}\"'.format(self.action,
action))
cmd = action
args = [templater.generate_string(a) for a in self.args]
try:
cmd = action.format(*self.args)
cmd = action.format(*args)
except IndexError:
err = 'bad action: \"{}\"'.format(action)
err += ' with \"{}\"'.format(self.args)
err += ' with \"{}\"'.format(args)
self.log.warn(err)
return False
self.log.sub('executing \"{}\"'.format(cmd))