mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-05 17:18:53 +00:00
add clear_workdir and -W for #330
This commit is contained in:
@@ -317,6 +317,14 @@ def cmd_install(opts):
|
||||
|
||||
installed = []
|
||||
|
||||
# clear the workdir
|
||||
if opts.install_clear_workdir and not opts.dry:
|
||||
LOG.dbg('clearing the workdir under {}'.format(opts.workdir))
|
||||
for root, _, files in os.walk(opts.workdir):
|
||||
for file in files:
|
||||
fpath = os.path.join(root, file)
|
||||
removepath(fpath, logger=LOG)
|
||||
|
||||
# execute profile pre-action
|
||||
LOG.dbg('run {} profile pre actions'.format(len(pro_pre_actions)))
|
||||
templ = _get_templater(opts)
|
||||
|
||||
@@ -56,18 +56,18 @@ USAGE = """
|
||||
{}
|
||||
|
||||
Usage:
|
||||
dotdrop install [-VbtfndDa] [-c <path>] [-p <profile>]
|
||||
[-w <nb>] [<key>...]
|
||||
dotdrop import [-Vbdfm] [-c <path>] [-p <profile>] [-s <path>]
|
||||
[-l <link>] [-i <pattern>...] <path>...
|
||||
dotdrop compare [-LVbz] [-c <path>] [-p <profile>]
|
||||
[-w <nb>] [-C <file>...] [-i <pattern>...]
|
||||
dotdrop update [-VbfdkPz] [-c <path>] [-p <profile>]
|
||||
[-w <nb>] [-i <pattern>...] [<path>...]
|
||||
dotdrop remove [-Vbfdk] [-c <path>] [-p <profile>] [<path>...]
|
||||
dotdrop files [-VbTG] [-c <path>] [-p <profile>]
|
||||
dotdrop detail [-Vb] [-c <path>] [-p <profile>] [<key>...]
|
||||
dotdrop profiles [-VbG] [-c <path>]
|
||||
dotdrop install [-VbtfndDaW] [-c <path>] [-p <profile>]
|
||||
[-w <nb>] [<key>...]
|
||||
dotdrop import [-Vbdfm] [-c <path>] [-p <profile>] [-s <path>]
|
||||
[-l <link>] [-i <pattern>...] <path>...
|
||||
dotdrop compare [-LVbz] [-c <path>] [-p <profile>]
|
||||
[-w <nb>] [-C <file>...] [-i <pattern>...]
|
||||
dotdrop update [-VbfdkPz] [-c <path>] [-p <profile>]
|
||||
[-w <nb>] [-i <pattern>...] [<path>...]
|
||||
dotdrop remove [-Vbfdk] [-c <path>] [-p <profile>] [<path>...]
|
||||
dotdrop files [-VbTG] [-c <path>] [-p <profile>]
|
||||
dotdrop detail [-Vb] [-c <path>] [-p <profile>] [<key>...]
|
||||
dotdrop profiles [-VbG] [-c <path>]
|
||||
dotdrop --help
|
||||
dotdrop --version
|
||||
|
||||
@@ -93,6 +93,7 @@ Options:
|
||||
-T --template Only template dotfiles.
|
||||
-V --verbose Be verbose.
|
||||
-w --workers=<nb> Number of concurrent workers [default: 1].
|
||||
-W --workdir-clear Clear the workdir.
|
||||
-z --ignore-missing Ignore files in installed folders that are missing.
|
||||
-v --version Show version.
|
||||
-h --help Show this screen.
|
||||
@@ -244,6 +245,7 @@ class Options(AttrMonitor):
|
||||
if a.kind == Action.post]
|
||||
self.install_ignore = self.instignore
|
||||
self.install_force_chmod = self.force_chmod
|
||||
self.install_clear_workdir = self.args['--workdir-clear'] or self.clear_workdir
|
||||
|
||||
def _apply_args_compare(self):
|
||||
"""compare specifics"""
|
||||
|
||||
@@ -46,6 +46,7 @@ class Settings(DictParser):
|
||||
key_ignore_missing_in_dotdrop = 'ignore_missing_in_dotdrop'
|
||||
key_chmod_on_import = 'chmod_on_import'
|
||||
key_check_version = 'check_version'
|
||||
key_clear_workdir = 'clear_workdir'
|
||||
|
||||
# import keys
|
||||
key_import_actions = 'import_actions'
|
||||
@@ -65,9 +66,8 @@ class Settings(DictParser):
|
||||
diff_command='diff -r -u {0} {1}',
|
||||
template_dotfile_default=True,
|
||||
ignore_missing_in_dotdrop=False,
|
||||
force_chmod=False,
|
||||
chmod_on_import=False,
|
||||
check_version=False):
|
||||
force_chmod=False, chmod_on_import=False,
|
||||
check_version=False, clear_workdir=False):
|
||||
self.backup = backup
|
||||
self.banner = banner
|
||||
self.create = create
|
||||
@@ -98,6 +98,7 @@ class Settings(DictParser):
|
||||
self.force_chmod = force_chmod
|
||||
self.chmod_on_import = chmod_on_import
|
||||
self.check_version = check_version
|
||||
self.clear_workdir = clear_workdir
|
||||
|
||||
def _serialize_seq(self, name, dic):
|
||||
"""serialize attribute 'name' into 'dic'"""
|
||||
@@ -125,6 +126,7 @@ class Settings(DictParser):
|
||||
self.key_force_chmod: self.force_chmod,
|
||||
self.key_chmod_on_import: self.chmod_on_import,
|
||||
self.key_check_version: self.check_version,
|
||||
self.key_clear_workdir: self.clear_workdir,
|
||||
}
|
||||
self._serialize_seq(self.key_default_actions, dic)
|
||||
self._serialize_seq(self.key_import_actions, dic)
|
||||
|
||||
Reference in New Issue
Block a user