mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-08 10:14:17 +00:00
fix action usage variable expansion
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -46,7 +46,7 @@ def action_executor(o, actions, defactions, templater, post=False):
|
||||
continue
|
||||
if o.debug:
|
||||
LOG.dbg('executing def-{}-action {}'.format(s, action))
|
||||
ret = action.execute(templater=templater)
|
||||
ret = action.execute(templater=templater, debug=o.debug)
|
||||
if not ret:
|
||||
err = 'def-{}-action \"{}\" failed'.format(s, action.key)
|
||||
LOG.err(err)
|
||||
@@ -59,7 +59,7 @@ def action_executor(o, actions, defactions, templater, post=False):
|
||||
continue
|
||||
if o.debug:
|
||||
LOG.dbg('executing {}-action {}'.format(s, action))
|
||||
ret = action.execute(templater=templater)
|
||||
ret = action.execute(templater=templater, debug=o.debug)
|
||||
if not ret:
|
||||
err = '{}-action \"{}\" failed'.format(s, action.key)
|
||||
LOG.err(err)
|
||||
|
||||
Reference in New Issue
Block a user