mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-04 09:51:45 +00:00
adding a gencfg command
This commit is contained in:
5
README.md
vendored
5
README.md
vendored
@@ -98,8 +98,9 @@ Dotdrop is available on:
|
||||
# Getting started
|
||||
|
||||
[Create a new repository](https://dotdrop.readthedocs.io/en/latest/getting-started/#repository-setup)
|
||||
to store your dotfiles with dotdrop. *Init* or *clone* that new repository and
|
||||
[install dotdrop](https://dotdrop.readthedocs.io/en/latest/installation/).
|
||||
to store your dotfiles with dotdrop. *Init* or *clone* that new repository,
|
||||
[install dotdrop](https://dotdrop.readthedocs.io/en/latest/installation/) and
|
||||
generate a default config file [generate config file](https://dotdrop.readthedocs.io/en/latest/usage/#generate-a-default-config)
|
||||
|
||||
Then import any dotfiles (files or directories) you want to manage with dotdrop.
|
||||
You can either use the default profile (which resolves to the *hostname* of the host
|
||||
|
||||
14
bootstrap.sh
vendored
14
bootstrap.sh
vendored
@@ -2,22 +2,14 @@
|
||||
# author: deadc0de6 (https://github.com/deadc0de6)
|
||||
# Copyright (c) 2017, deadc0de6
|
||||
|
||||
fold="dotfiles"
|
||||
conf="config.yaml"
|
||||
|
||||
# copy dotdrop entry point
|
||||
cp dotdrop/dotdrop.sh dotdrop.sh
|
||||
chmod +x dotdrop.sh
|
||||
mkdir -p $fold
|
||||
mkdir -p dotfiles
|
||||
|
||||
if [ ! -e ${conf} ]; then
|
||||
if [ ! -e "${conf}" ]; then
|
||||
# init config file
|
||||
cat << EOF > ${conf}
|
||||
config:
|
||||
backup: true
|
||||
create: true
|
||||
dotpath: $fold
|
||||
dotfiles:
|
||||
profiles:
|
||||
EOF
|
||||
./dotdrop.sh gencfg > "${conf}"
|
||||
fi
|
||||
|
||||
1
docs/config/config-config.md
vendored
1
docs/config/config-config.md
vendored
@@ -38,7 +38,6 @@ Entry | Description | Default
|
||||
`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
|
||||
|
||||
|
||||
## import_variables entry
|
||||
|
||||
It is possible to load variables/dynvariables from external files by providing their
|
||||
|
||||
4
docs/config/config-file.md
vendored
4
docs/config/config-file.md
vendored
@@ -2,8 +2,8 @@
|
||||
|
||||
## Location
|
||||
|
||||
The default config file used by dotdrop is
|
||||
[config.yaml](https://github.com/deadc0de6/dotdrop/blob/master/config.yaml).
|
||||
The default config file used by dotdrop is `config.yaml`.
|
||||
A clean base config can be generated using `dotdrop gencfg`.
|
||||
|
||||
Unless specified otherwise, dotdrop will look in the following places for its config file
|
||||
and use the first one found:
|
||||
|
||||
7
docs/getting-started.md
vendored
7
docs/getting-started.md
vendored
@@ -15,12 +15,11 @@ $ cd my-dotfiles
|
||||
$ mkdir dotfiles
|
||||
```
|
||||
|
||||
Then add a config file. You can get a
|
||||
[minimal config file](https://github.com/deadc0de6/dotdrop/blob/master/config.yaml)
|
||||
from dotdrop's repository with:
|
||||
Then generate a base config file:
|
||||
```bash
|
||||
$ wget https://raw.githubusercontent.com/deadc0de6/dotdrop/master/config.yaml
|
||||
$ dotdrop gencfg > config.yaml
|
||||
```
|
||||
|
||||
It is recommended to store your config file directly within your repository
|
||||
(*my-dotfiles* in the example above), but you could save it in different places if you wish;
|
||||
see [config location](config/config-file.md#location) for more.
|
||||
|
||||
7
docs/usage.md
vendored
7
docs/usage.md
vendored
@@ -250,6 +250,13 @@ the file will be restored.
|
||||
|
||||
For more options, see the usage with `dotdrop --help`.
|
||||
|
||||
## Generate a default config
|
||||
|
||||
The `gencfg` command will generate a default config in yaml
|
||||
```bash
|
||||
$ dotdrop gencfg > config.yaml
|
||||
```
|
||||
|
||||
## Concurrency
|
||||
|
||||
The command line switch `-w`/`--workers`, if set to a value greater than one, enables the use
|
||||
|
||||
18
dotdrop/config.py
Normal file
18
dotdrop/config.py
Normal file
@@ -0,0 +1,18 @@
|
||||
"""
|
||||
author: deadc0de6 (https://github.com/deadc0de6)
|
||||
Copyright (c) 2024, deadc0de6
|
||||
|
||||
default config
|
||||
"""
|
||||
|
||||
default_config = """config:
|
||||
backup: true
|
||||
banner: true
|
||||
create: true
|
||||
dotpath: dotfiles
|
||||
keepdot: false
|
||||
link_dotfile_default: nolink
|
||||
link_on_import: nolink
|
||||
longkey: false
|
||||
dotfiles:
|
||||
profiles:"""
|
||||
@@ -21,6 +21,7 @@ from dotdrop.cfg_aggregator import CfgAggregator
|
||||
from dotdrop.action import Action
|
||||
from dotdrop.utils import uniq_list, debug_list, debug_dict
|
||||
from dotdrop.exceptions import YamlException, OptionsException
|
||||
from dotdrop.config import default_config
|
||||
|
||||
ENV_PROFILE = 'DOTDROP_PROFILE'
|
||||
ENV_CONFIG = 'DOTDROP_CONFIG'
|
||||
@@ -72,6 +73,7 @@ Usage:
|
||||
dotdrop files [-VbTG] [-c <path>] [-p <profile>]
|
||||
dotdrop detail [-Vb] [-c <path>] [-p <profile>] [<key>...]
|
||||
dotdrop profiles [-VbG] [-c <path>]
|
||||
dotdrop gencfg
|
||||
dotdrop --help
|
||||
dotdrop --version
|
||||
|
||||
@@ -148,6 +150,12 @@ class Options(AttrMonitor):
|
||||
self.args = {}
|
||||
if not args:
|
||||
self.args = docopt(USAGE, version=VERSION)
|
||||
|
||||
if self.args['gencfg']:
|
||||
# print config and exit
|
||||
print(default_config)
|
||||
sys.exit(0)
|
||||
|
||||
if args:
|
||||
self.args = args.copy()
|
||||
self.debug = self.args['--verbose'] or ENV_DEBUG in os.environ
|
||||
|
||||
Reference in New Issue
Block a user