1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-07 12:13:32 +00:00

adding --force-action for #149

This commit is contained in:
deadc0de6
2019-06-02 12:32:58 +02:00
parent 936f919062
commit 8af57adfab
7 changed files with 154 additions and 13 deletions

View File

@@ -129,6 +129,7 @@ def cmd_install(o):
if os.path.exists(tmp):
remove(tmp)
if r:
# dotfile was installed
if not o.install_temporary:
defactions = o.install_default_actions_post
postactions = dotfile.get_post_actions()
@@ -136,8 +137,19 @@ def cmd_install(o):
defactions, t, post=True)
post_actions_exec()
installed += 1
elif not r and err:
LOG.err('installing \"{}\" failed: {}'.format(dotfile.key, err))
elif not r:
# dotfile was NOT installed
if o.install_force_action:
LOG.dbg('force pre action execution ...')
pre_actions_exec()
LOG.dbg('force post pre action execution ...')
postactions = dotfile.get_post_actions()
post_actions_exec = action_executor(o, dotfile, postactions,
defactions, t, post=True)
post_actions_exec()
if err:
LOG.err('installing \"{}\" failed: {}'.format(dotfile.key,
err))
if o.install_temporary:
LOG.log('\ninstalled to tmp \"{}\".'.format(tmpdir))
LOG.log('\n{} dotfile(s) installed.'.format(installed))

View File

@@ -50,15 +50,15 @@ USAGE = """
{}
Usage:
dotdrop install [-VbtfndD] [-c <path>] [-p <profile>] [<key>...]
dotdrop import [-Vbd] [-c <path>] [-p <profile>] [-l <link>] <path>...
dotdrop compare [-Vb] [-c <path>] [-p <profile>]
[-o <opts>] [-C <file>...] [-i <pattern>...]
dotdrop update [-VbfdkP] [-c <path>] [-p <profile>]
[-i <pattern>...] [<path>...]
dotdrop listfiles [-VbT] [-c <path>] [-p <profile>]
dotdrop detail [-Vb] [-c <path>] [-p <profile>] [<key>...]
dotdrop list [-Vb] [-c <path>]
dotdrop install [-VbtfndDa] [-c <path>] [-p <profile>] [<key>...]
dotdrop import [-Vbd] [-c <path>] [-p <profile>] [-l <link>] <path>...
dotdrop compare [-Vb] [-c <path>] [-p <profile>]
[-o <opts>] [-C <file>...] [-i <pattern>...]
dotdrop update [-VbfdkP] [-c <path>] [-p <profile>]
[-i <pattern>...] [<path>...]
dotdrop listfiles [-VbT] [-c <path>] [-p <profile>]
dotdrop detail [-Vb] [-c <path>] [-p <profile>] [<key>...]
dotdrop list [-Vb] [-c <path>]
dotdrop --help
dotdrop --version
@@ -75,6 +75,7 @@ Options:
-D --showdiff Show a diff before overwriting.
-P --show-patch Provide a one-liner to manually patch template.
-f --force Do not ask user confirmation for anything.
-a --force-action Execute all actions even if no dotfile is installed.
-k --key Treat <path> as a dotfile key.
-V --verbose Be verbose.
-d --dry Dry run.
@@ -209,6 +210,7 @@ class Options(AttrMonitor):
# "listfiles" specifics
self.listfiles_templateonly = self.args['--template']
# "install" specifics
self.install_force_action = self.args['--force-action']
self.install_temporary = self.args['--temp']
self.install_keys = self.args['<key>']
self.install_diff = not self.args['--nodiff']