mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-11 00:54:16 +00:00
add clear_workdir and -W for #330
This commit is contained in:
@@ -15,6 +15,7 @@ Entry | Description | Default
|
|||||||
`banner` | Display the banner | true
|
`banner` | Display the banner | true
|
||||||
`check_version` | Check if a new version of dotdrop is available on github | false
|
`check_version` | Check if a new version of dotdrop is available on github | false
|
||||||
`chmod_on_import` | Always add a chmod entry on newly imported dotfiles (see `--preserve-mode`) | false
|
`chmod_on_import` | Always add a chmod entry on newly imported dotfiles (see `--preserve-mode`) | false
|
||||||
|
`clear_workdir` | Clear the `workdir` before install | false
|
||||||
`cmpignore` | List of patterns to ignore when comparing, applied to all dotfiles (enclose in quotes when using wildcards; see [ignore patterns](config.md#ignore-patterns)) | -
|
`cmpignore` | List of patterns to ignore when comparing, applied to all dotfiles (enclose in quotes when using wildcards; see [ignore patterns](config.md#ignore-patterns)) | -
|
||||||
`create` | Create a directory hierarchy when installing dotfiles if it doesn't exist | true
|
`create` | Create a directory hierarchy when installing dotfiles if it doesn't exist | true
|
||||||
`default_actions` | List of action keys to execute for all installed dotfiles (See [actions](config-details.md#actions-entry)) | -
|
`default_actions` | List of action keys to execute for all installed dotfiles (See [actions](config-details.md#actions-entry)) | -
|
||||||
|
|||||||
@@ -317,6 +317,14 @@ def cmd_install(opts):
|
|||||||
|
|
||||||
installed = []
|
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
|
# execute profile pre-action
|
||||||
LOG.dbg('run {} profile pre actions'.format(len(pro_pre_actions)))
|
LOG.dbg('run {} profile pre actions'.format(len(pro_pre_actions)))
|
||||||
templ = _get_templater(opts)
|
templ = _get_templater(opts)
|
||||||
|
|||||||
@@ -56,18 +56,18 @@ USAGE = """
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
dotdrop install [-VbtfndDa] [-c <path>] [-p <profile>]
|
dotdrop install [-VbtfndDaW] [-c <path>] [-p <profile>]
|
||||||
[-w <nb>] [<key>...]
|
[-w <nb>] [<key>...]
|
||||||
dotdrop import [-Vbdfm] [-c <path>] [-p <profile>] [-s <path>]
|
dotdrop import [-Vbdfm] [-c <path>] [-p <profile>] [-s <path>]
|
||||||
[-l <link>] [-i <pattern>...] <path>...
|
[-l <link>] [-i <pattern>...] <path>...
|
||||||
dotdrop compare [-LVbz] [-c <path>] [-p <profile>]
|
dotdrop compare [-LVbz] [-c <path>] [-p <profile>]
|
||||||
[-w <nb>] [-C <file>...] [-i <pattern>...]
|
[-w <nb>] [-C <file>...] [-i <pattern>...]
|
||||||
dotdrop update [-VbfdkPz] [-c <path>] [-p <profile>]
|
dotdrop update [-VbfdkPz] [-c <path>] [-p <profile>]
|
||||||
[-w <nb>] [-i <pattern>...] [<path>...]
|
[-w <nb>] [-i <pattern>...] [<path>...]
|
||||||
dotdrop remove [-Vbfdk] [-c <path>] [-p <profile>] [<path>...]
|
dotdrop remove [-Vbfdk] [-c <path>] [-p <profile>] [<path>...]
|
||||||
dotdrop files [-VbTG] [-c <path>] [-p <profile>]
|
dotdrop files [-VbTG] [-c <path>] [-p <profile>]
|
||||||
dotdrop detail [-Vb] [-c <path>] [-p <profile>] [<key>...]
|
dotdrop detail [-Vb] [-c <path>] [-p <profile>] [<key>...]
|
||||||
dotdrop profiles [-VbG] [-c <path>]
|
dotdrop profiles [-VbG] [-c <path>]
|
||||||
dotdrop --help
|
dotdrop --help
|
||||||
dotdrop --version
|
dotdrop --version
|
||||||
|
|
||||||
@@ -93,6 +93,7 @@ Options:
|
|||||||
-T --template Only template dotfiles.
|
-T --template Only template dotfiles.
|
||||||
-V --verbose Be verbose.
|
-V --verbose Be verbose.
|
||||||
-w --workers=<nb> Number of concurrent workers [default: 1].
|
-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.
|
-z --ignore-missing Ignore files in installed folders that are missing.
|
||||||
-v --version Show version.
|
-v --version Show version.
|
||||||
-h --help Show this screen.
|
-h --help Show this screen.
|
||||||
@@ -244,6 +245,7 @@ class Options(AttrMonitor):
|
|||||||
if a.kind == Action.post]
|
if a.kind == Action.post]
|
||||||
self.install_ignore = self.instignore
|
self.install_ignore = self.instignore
|
||||||
self.install_force_chmod = self.force_chmod
|
self.install_force_chmod = self.force_chmod
|
||||||
|
self.install_clear_workdir = self.args['--workdir-clear'] or self.clear_workdir
|
||||||
|
|
||||||
def _apply_args_compare(self):
|
def _apply_args_compare(self):
|
||||||
"""compare specifics"""
|
"""compare specifics"""
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ class Settings(DictParser):
|
|||||||
key_ignore_missing_in_dotdrop = 'ignore_missing_in_dotdrop'
|
key_ignore_missing_in_dotdrop = 'ignore_missing_in_dotdrop'
|
||||||
key_chmod_on_import = 'chmod_on_import'
|
key_chmod_on_import = 'chmod_on_import'
|
||||||
key_check_version = 'check_version'
|
key_check_version = 'check_version'
|
||||||
|
key_clear_workdir = 'clear_workdir'
|
||||||
|
|
||||||
# import keys
|
# import keys
|
||||||
key_import_actions = 'import_actions'
|
key_import_actions = 'import_actions'
|
||||||
@@ -65,9 +66,8 @@ class Settings(DictParser):
|
|||||||
diff_command='diff -r -u {0} {1}',
|
diff_command='diff -r -u {0} {1}',
|
||||||
template_dotfile_default=True,
|
template_dotfile_default=True,
|
||||||
ignore_missing_in_dotdrop=False,
|
ignore_missing_in_dotdrop=False,
|
||||||
force_chmod=False,
|
force_chmod=False, chmod_on_import=False,
|
||||||
chmod_on_import=False,
|
check_version=False, clear_workdir=False):
|
||||||
check_version=False):
|
|
||||||
self.backup = backup
|
self.backup = backup
|
||||||
self.banner = banner
|
self.banner = banner
|
||||||
self.create = create
|
self.create = create
|
||||||
@@ -98,6 +98,7 @@ class Settings(DictParser):
|
|||||||
self.force_chmod = force_chmod
|
self.force_chmod = force_chmod
|
||||||
self.chmod_on_import = chmod_on_import
|
self.chmod_on_import = chmod_on_import
|
||||||
self.check_version = check_version
|
self.check_version = check_version
|
||||||
|
self.clear_workdir = clear_workdir
|
||||||
|
|
||||||
def _serialize_seq(self, name, dic):
|
def _serialize_seq(self, name, dic):
|
||||||
"""serialize attribute 'name' into 'dic'"""
|
"""serialize attribute 'name' into 'dic'"""
|
||||||
@@ -125,6 +126,7 @@ class Settings(DictParser):
|
|||||||
self.key_force_chmod: self.force_chmod,
|
self.key_force_chmod: self.force_chmod,
|
||||||
self.key_chmod_on_import: self.chmod_on_import,
|
self.key_chmod_on_import: self.chmod_on_import,
|
||||||
self.key_check_version: self.check_version,
|
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_default_actions, dic)
|
||||||
self._serialize_seq(self.key_import_actions, dic)
|
self._serialize_seq(self.key_import_actions, dic)
|
||||||
|
|||||||
Reference in New Issue
Block a user