mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-04 15:39:43 +00:00
update doc and tests for link
This commit is contained in:
@@ -72,7 +72,7 @@ set -l f -s f -l force -d "Do not ask user confirmation for anything."
|
||||
set -l G -s G -l grepable -d "Grepable output."
|
||||
set -l i -s i -l ignore -d "Pattern to ignore."
|
||||
set -l k -s k -l key -d "Treat <path> as a dotfile key."
|
||||
set -l l -s l -l link -d "Link option (nolink|link|link_children)."
|
||||
set -l l -s l -l link -d "Link option (nolink|absolute|relative|link_children)."
|
||||
set -l L -s L -l file-only -d "Do not show diff but only the files that differ."
|
||||
set -l m -s m -l preserve-mode -d "Insert a chmod entry in the dotfile with its mode."
|
||||
set -l n -s n -l nodiff -d "Do not diff when installing."
|
||||
@@ -91,7 +91,7 @@ set -l h -s h -l help -d "Show this screen."
|
||||
set -al c -rF
|
||||
set -al C -rF
|
||||
set -al i -x
|
||||
set -al l -x -a "nolink link link_children"
|
||||
set -al l -x -a "nolink absolute relative link_children"
|
||||
set -al p -x -a "(__fish_dotdrop_list_profiles)"
|
||||
set -al s -rF
|
||||
set -al w -x
|
||||
|
||||
@@ -28,14 +28,14 @@ Entry | Description | Default
|
||||
`keepdot` | Preserve leading dot when importing hidden file in the `dotpath` | false
|
||||
`key_prefix` | Prefix dotfile key on `import` with `f<key_separator>` for file and `d<key_separator>` for directory | true
|
||||
`key_separator` | Separator to use on dotfile key generation on `import` | `_`
|
||||
`link_dotfile_default` | Set a dotfile's `link` attribute to this value when undefined. Possible values: *nolink*, *link* (See [Symlinking dotfiles](config-file.md#symlinking-dotfiles)) | `nolink`
|
||||
`link_on_import` | Set a dotfile's `link` attribute to this value when importing. Possible values: *nolink*, *link* [Symlinking dotfiles](config-file.md#symlinking-dotfiles)) | `nolink`
|
||||
`link_dotfile_default` | Set a dotfile's `link` attribute to this value when undefined. Possible values: *nolink*, *absolute*, *relative* (See [Symlinking dotfiles](config-file.md#symlinking-dotfiles)) | `nolink`
|
||||
`link_on_import` | Set a dotfile's `link` attribute to this value when importing. Possible values: *nolink*, *absolute*, *relative* [Symlinking dotfiles](config-file.md#symlinking-dotfiles)) | `nolink`
|
||||
`longkey` | Use long keys for dotfiles when importing (See [Import dotfiles](usage.md#import-dotfiles)) | false
|
||||
`minversion` | (*for internal use, do not modify*) Provides the minimal dotdrop version to use | -
|
||||
`showdiff` | On install, show a diff before asking to overwrite (See `--showdiff`) | false
|
||||
`template_dotfile_default` | Disable templating on all dotfiles when set to false | true
|
||||
`upignore` | List of patterns to ignore when updating, appled to all dotfiles (enclose in quotes when using wildcards; see [ignore patterns](config-file.md#ignore-patterns)) | -
|
||||
`workdir` | Path to the directory where templates are installed before being symlinked when using `link:link` or `link:link_children` (absolute path or relative to the config file location) | `~/.config/dotdrop`
|
||||
`workdir` | Path to the directory where templates are installed before being symlinked when using `link:absolute|relative|link_children` (absolute path or relative to the config file location) | `~/.config/dotdrop`
|
||||
<s>link_by_default</s> | When importing a dotfile, set `link` to this value by default | false
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ Entry | Description
|
||||
-------- | -------------
|
||||
`dst` | Where this dotfile needs to be deployed (dotfiles with empty `dst` are ignored and considered installed, can use `variables`, make sure to quote)
|
||||
`src` | Dotfile path within the `dotpath` (dotfiles with empty `src` are ignored and considered installed, can use `variables`, make sure to quote)
|
||||
`link` | Defines how this dotfile is installed. Possible values: *nolink*, *link*, *link_children* (See [Symlinking dotfiles](config-file.md#symlinking-dotfiles)) (defaults to value of `link_dotfile_default`)
|
||||
`link` | Defines how this dotfile is installed. Possible values: *nolink*, *absolute*, *relative*, *link_children* (See [Symlinking dotfiles](config-file.md#symlinking-dotfiles)) (defaults to value of `link_dotfile_default`)
|
||||
`actions` | List of action keys that need to be defined in the **actions** entry below (See [actions](config-actions.md))
|
||||
`chmod` | Defines the file permissions in octal notation to apply during installation (See [permissions](config-file.md#permissions))
|
||||
`cmpignore` | List of patterns to ignore when comparing (enclose in quotes when using wildcards; see [ignore patterns](config-file.md#ignore-patterns))
|
||||
@@ -25,7 +25,7 @@ Entry | Description
|
||||
dst: <where-this-file-is-deployed>
|
||||
src: <filename-within-the-dotpath>
|
||||
## Optional
|
||||
link: (nolink|link|link_children)
|
||||
link: (nolink|absolute|relative|link_children)
|
||||
ignoreempty: (true|false)
|
||||
cmpignore:
|
||||
- "<ignore-pattern>"
|
||||
@@ -209,7 +209,7 @@ profiles:
|
||||
dotfiles:
|
||||
- f_test
|
||||
variables:
|
||||
link_value: "link"
|
||||
link_value: "absolute"
|
||||
windows:
|
||||
dotfiles:
|
||||
- f_test
|
||||
|
||||
@@ -119,7 +119,8 @@ Dotdrop is able to install dotfiles in three different ways,
|
||||
which are controlled by the `link` config attribute of each dotfile:
|
||||
|
||||
* `link: nolink`: The dotfile (file or directory) is copied to its destination
|
||||
* `link: link`: The dotfile (file or directory) is symlinked to its destination
|
||||
* `link: absolute`: The dotfile (file or directory) is linked to its destination using an absolute symlink
|
||||
* `link: relative`: The dotfile (file or directory) is linked to its destination using a relative symlink
|
||||
* `link: link_children`: The files/directories found under the dotfile (directory) are symlinked to their destination
|
||||
|
||||
For more, see [this how-to](howto/symlink-dotfiles.md).
|
||||
|
||||
@@ -30,7 +30,7 @@ There are two types of transformations available:
|
||||
A typical use-case for transformations is when dotfiles need to be
|
||||
stored encrypted or compressed. For more, see [the howto](howto/howto.md).
|
||||
|
||||
Note that transformations cannot be used if the dotfile is to be linked (when `link: link` or `link: link_children`).
|
||||
Note that transformations cannot be used if the dotfile is to be linked (when `link: absolute|relative|link_children`).
|
||||
|
||||
Transformations also support additional positional arguments that must start from 2 (since `{0}` and `{1}` are added automatically). The transformations themselves as well as their arguments can also be templated.
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Dotdrop offers two ways to symlink a dotfile through its
|
||||
config entry `link`:
|
||||
|
||||
* Setting `link: link` for a dotfile will symlink `dst` to `src`
|
||||
* Setting `link: absolute` or `link: relative` for a dotfile will symlink `dst` to `src`
|
||||
* Setting `link: link_children` will, for every direct child of `src`, symlink `dst/<childrenX>` to `src/<childrenX>` (See [Link children](#link-children))
|
||||
|
||||
where `src` is the file stored in your *dotpath* and
|
||||
@@ -28,13 +28,13 @@ $ dotdrop import ~/.bashrc
|
||||
-> "/home/user/.bashrc" imported
|
||||
```
|
||||
|
||||
Edit the `config.yaml` and set the `link` value to `link`:
|
||||
Edit the `config.yaml` and set the `link` value to `absolute`:
|
||||
```yaml
|
||||
dotfiles:
|
||||
f_bashrc:
|
||||
src: bashrc
|
||||
dst: ~/.bashrc
|
||||
link: link
|
||||
link: absolute
|
||||
```
|
||||
|
||||
Install the dotfile, which will remove your `~/.bashrc` and replace it with a link to the file stored in dotdrop:
|
||||
@@ -64,7 +64,7 @@ Setting this option on a file that is not a directory will make any operation on
|
||||
|
||||
A good example of its use is when managing `~/.vim` with dotdrop.
|
||||
|
||||
Here's what it looks like when using `link: link`:
|
||||
Here's what it looks like when using `link: absolute`:
|
||||
```yaml
|
||||
config:
|
||||
dotpath: dotfiles
|
||||
@@ -72,7 +72,7 @@ dotfiles:
|
||||
vim:
|
||||
dst: ~/.vim
|
||||
src: vim
|
||||
link: link
|
||||
link: absolute
|
||||
```
|
||||
|
||||
The top directory `~/.vim` is symlinked to the `<dotpath>/vim` location:
|
||||
@@ -126,7 +126,7 @@ to dotdrop's `dotpath` directory (see [the config file doc](../config-file.md)).
|
||||
When using templating directives, however, the dotfiles are first installed into
|
||||
`workdir` (defaults to *~/.config/dotdrop*; see [the doc](../config-config.md))
|
||||
and then symlinked there.
|
||||
This applies to both dotfiles with `link: link` and `link: link_children`.
|
||||
This applies to both dotfiles with `link: absolute|relative` and `link: link_children`.
|
||||
|
||||
For example:
|
||||
```bash
|
||||
|
||||
@@ -14,7 +14,7 @@ Obviously, if the dotfile uses template directives, it needs to be templated. Ho
|
||||
is not, disabling templating will speed up its installation (since it won't have to be
|
||||
processed by the engine).
|
||||
|
||||
For dotfiles being symlinked (`link` or `link_children`), see
|
||||
For dotfiles being symlinked (`absolute`, `relative` or `link_children`), see
|
||||
[the dedicated doc](howto/symlink-dotfiles.md#templating-symlinked-dotfiles).
|
||||
|
||||
## Delimiters
|
||||
|
||||
@@ -224,7 +224,7 @@ def _dotfile_install(opts, dotfile, tmpdir=None):
|
||||
LinkTypes.LINK, LinkTypes.LINK_CHILDREN,
|
||||
LinkTypes.RELATIVE, LinkTypes.ABSOLUTE
|
||||
):
|
||||
# link|relative|absolute|link_children
|
||||
# nolink|relative|absolute|link_children
|
||||
ret, err = inst.install(templ, dotfile.src, dotfile.dst,
|
||||
dotfile.link,
|
||||
actionexec=pre_actions_exec,
|
||||
@@ -645,7 +645,7 @@ def cmd_remove(opts):
|
||||
k = dotfile.key
|
||||
# ignore if uses any type of link
|
||||
if dotfile.link != LinkTypes.NOLINK:
|
||||
msg = '{} uses link/link_children, remove manually'
|
||||
msg = '{} uses symlink, remove manually'
|
||||
LOG.warn(msg.format(k))
|
||||
continue
|
||||
|
||||
|
||||
@@ -43,7 +43,8 @@ ETCCFG = '/etc/{}'.format(NAME)
|
||||
|
||||
OPT_LINK = {
|
||||
LinkTypes.NOLINK.name.lower(): LinkTypes.NOLINK,
|
||||
LinkTypes.LINK.name.lower(): LinkTypes.LINK,
|
||||
LinkTypes.ABSOLUTE.name.lower(): LinkTypes.ABSOLUTE,
|
||||
LinkTypes.RELATIVE.name.lower(): LinkTypes.RELATIVE,
|
||||
LinkTypes.LINK_CHILDREN.name.lower(): LinkTypes.LINK_CHILDREN}
|
||||
|
||||
BANNER = r""" _ _ _
|
||||
@@ -82,7 +83,7 @@ Options:
|
||||
-G --grepable Grepable output.
|
||||
-i --ignore=<pattern> Pattern to ignore.
|
||||
-k --key Treat <path> as a dotfile key.
|
||||
-l --link=<link> Link option (nolink|link|link_children).
|
||||
-l --link=<link> Link option (nolink|absolute|relative|link_children).
|
||||
-L --file-only Do not show diff but only the files that differ.
|
||||
-m --preserve-mode Insert a chmod entry in the dotfile with its mode.
|
||||
-n --nodiff Do not diff when installing.
|
||||
|
||||
@@ -19,7 +19,7 @@ USAGE = """
|
||||
change-link.py
|
||||
|
||||
Usage:
|
||||
change-link.py (--true | --false) [--ignore=<dotfile-name>...] <config.yaml>
|
||||
change-link.py --value=<value> [--ignore=<dotfile-name>...] <config.yaml>
|
||||
change-link.py --help
|
||||
|
||||
Options:
|
||||
@@ -35,11 +35,7 @@ def main():
|
||||
"""entry point"""
|
||||
args = docopt(USAGE)
|
||||
path = os.path.expanduser(args['<config.yaml>'])
|
||||
if args['--true']:
|
||||
value = True
|
||||
if args['--false']:
|
||||
value = False
|
||||
|
||||
value = args['--value']
|
||||
ignores = args['--ignore']
|
||||
|
||||
with open(path, 'r') as file:
|
||||
|
||||
@@ -142,7 +142,7 @@ mkdir -p ${tmps}/dotfiles
|
||||
|
||||
# import without --preserve-mode and link
|
||||
for i in ${toimport}; do
|
||||
cd ${ddpath} | ${bin} import -c ${cfg} -l link -f -p p1 -V ${i}
|
||||
cd ${ddpath} | ${bin} import -c ${cfg} -l absolute -f -p p1 -V ${i}
|
||||
done
|
||||
|
||||
cat ${cfg}
|
||||
@@ -155,7 +155,7 @@ cnt=`cat ${cfg} | grep "chmod: '777'" | wc -l`
|
||||
[ "${cnt}" != "${tot}" ] && echo "not all chmod inserted (2)" && exit 1
|
||||
|
||||
tot=`echo ${toimport} | wc -w`
|
||||
cnt=`cat ${cfg} | grep 'link: link' | wc -l`
|
||||
cnt=`cat ${cfg} | grep 'link: absolute' | wc -l`
|
||||
[ "${cnt}" != "${tot}" ] && echo "not all link inserted" && exit 1
|
||||
|
||||
## --preserve-mode
|
||||
|
||||
@@ -129,7 +129,7 @@ set -e
|
||||
|
||||
# test values have been correctly updated
|
||||
echo "========> test for updated entries"
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -G | grep '^f_link' | head -1 | grep ',link:link,'
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -G | grep '^f_link' | head -1 | grep ',link:absolute,'
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -G | grep '^f_nolink' | head -1 | grep ',link:nolink,'
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -G | grep '^f_nolink1' | head -1 | grep ',link:nolink,'
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -G | grep '^f_children' | head -1 | grep ',link:link_children,'
|
||||
|
||||
@@ -102,7 +102,7 @@ inside="${tmps}/dotfiles/${tmpd}/abc"
|
||||
[ ! -e ${inside} ] && exit 1
|
||||
|
||||
cat ${cfg}
|
||||
cat ${cfg} | grep 'link: link' >/dev/null
|
||||
cat ${cfg} | grep 'link: absolute' >/dev/null
|
||||
|
||||
echo "OK"
|
||||
exit 0
|
||||
|
||||
@@ -181,11 +181,11 @@ _EOF
|
||||
|
||||
# import
|
||||
df="${tmpd}/qwert"
|
||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 ${df} -V --link=link
|
||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 ${df} -V --link=absolute
|
||||
|
||||
# checks
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V -G | grep "f_`basename ${df}`" | head -1 | grep ',link:link,'
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V -G | grep "f_`basename ${df}`" | head -1 | grep ',link:absolute,'
|
||||
|
||||
# try to install
|
||||
rm -rf ${tmpd}/qwert
|
||||
@@ -219,7 +219,7 @@ cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 ${df} -V
|
||||
|
||||
# checks
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V -G | grep "f_`basename ${df}`" | head -1 | grep ',link:link,'
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V -G | grep "f_`basename ${df}`" | head -1 | grep ',link:absolute,'
|
||||
|
||||
# try to install
|
||||
rm -rf ${tmpd}/qwert
|
||||
@@ -349,11 +349,11 @@ _EOF
|
||||
|
||||
# import
|
||||
df="${tmpd}/qwert"
|
||||
cd ${ddpath} | ${bin} import -f -c ${cfg} --link=link -p p1 ${df} -V
|
||||
cd ${ddpath} | ${bin} import -f -c ${cfg} --link=absolute -p p1 ${df} -V
|
||||
|
||||
# checks
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V -G | grep "f_`basename ${df}`" | head -1 | grep ',link:link,'
|
||||
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V -G | grep "f_`basename ${df}`" | head -1 | grep ',link:absolute,'
|
||||
|
||||
# try to install
|
||||
rm -rf ${tmpd}/qwert
|
||||
|
||||
@@ -80,7 +80,7 @@ cd ${ddpath} | ${bin} compare -c ${cfg} -p p1 -V
|
||||
|
||||
# ensure minversion is present
|
||||
cat ${cfg}
|
||||
grep 'link: link' ${cfg}
|
||||
grep 'link: absolute' ${cfg}
|
||||
grep 'minversion' ${cfg}
|
||||
|
||||
# fake a higher version
|
||||
|
||||
@@ -51,17 +51,20 @@ class TestConfig(SubsetTestCase):
|
||||
self.assertTrue(conf.dump() != '')
|
||||
|
||||
def test_def_link(self):
|
||||
self._test_link_import('nolink', LinkTypes.LINK, 'link')
|
||||
self._test_link_import('nolink', LinkTypes.ABSOLUTE, 'absolute')
|
||||
self._test_link_import('nolink', LinkTypes.RELATIVE, 'relative')
|
||||
self._test_link_import('nolink', LinkTypes.NOLINK, 'nolink')
|
||||
self._test_link_import('nolink',
|
||||
LinkTypes.LINK_CHILDREN,
|
||||
'link_children')
|
||||
self._test_link_import('link', LinkTypes.LINK, 'link')
|
||||
self._test_link_import('link', LinkTypes.ABSOLUTE, 'absolute')
|
||||
self._test_link_import('link', LinkTypes.RELATIVE, 'relative')
|
||||
self._test_link_import('link', LinkTypes.NOLINK, 'nolink')
|
||||
self._test_link_import('link',
|
||||
LinkTypes.LINK_CHILDREN,
|
||||
'link_children')
|
||||
self._test_link_import('link_children', LinkTypes.LINK, 'link')
|
||||
self._test_link_import('link_children', LinkTypes.ABSOLUTE, 'absolute')
|
||||
self._test_link_import('link_children', LinkTypes.RELATIVE, 'relative')
|
||||
self._test_link_import('link_children', LinkTypes.NOLINK, 'nolink')
|
||||
self._test_link_import('link_children', LinkTypes.LINK_CHILDREN,
|
||||
'link_children')
|
||||
|
||||
Reference in New Issue
Block a user