dotctl 1.0.8__tar.gz → 1.0.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dotctl-1.0.8/src/dotctl.egg-info → dotctl-1.0.9}/PKG-INFO +25 -2
- {dotctl-1.0.8 → dotctl-1.0.9}/README.md +24 -1
- {dotctl-1.0.8 → dotctl-1.0.9}/pyproject.toml +1 -1
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/actions/saver.py +48 -2
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/arg_manager.py +7 -1
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/handlers/data_handler.py +80 -24
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/main.py +2 -1
- {dotctl-1.0.8 → dotctl-1.0.9/src/dotctl.egg-info}/PKG-INFO +25 -2
- {dotctl-1.0.8 → dotctl-1.0.9}/LICENSE +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/setup.cfg +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/__init__.py +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/actions/__init__.py +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/actions/activator.py +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/actions/creator.py +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/actions/exporter.py +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/actions/importer.py +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/actions/initializer.py +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/actions/lister.py +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/actions/puller.py +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/actions/remover.py +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/actions/switcher.py +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/actions/wiper.py +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/exception.py +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/handlers/__init__.py +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/handlers/config_handler.py +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/handlers/git_handler.py +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/handlers/hooks_handler.py +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/hooks/post_apply.sh +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/hooks/pre_apply.sh +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/paths.py +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/templates/__init__.py +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/templates/dev.yaml +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/templates/kde.yaml +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/templates/other.yaml +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/utils.py +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl/validators.py +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl.egg-info/SOURCES.txt +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl.egg-info/dependency_links.txt +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl.egg-info/entry_points.txt +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl.egg-info/requires.txt +0 -0
- {dotctl-1.0.8 → dotctl-1.0.9}/src/dotctl.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dotctl
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.9
|
|
4
4
|
Summary: A powerful CLI tool to profile your OS by saving, applying, exporting, and importing system configurations as named profiles. Designed to manage dot files and service configurations in a centralized Git repository (local or remote), dotctl enables seamless system replication across machines. Supports pre/post hook scripts, making it ideal for setting up servers or desktops with consistent environments.
|
|
5
5
|
Author-email: Pankaj Jackson <pankajackson@live.co.uk>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -57,6 +57,7 @@ Designed for developers and sysadmins, it supports pre/post hook scripts and is
|
|
|
57
57
|
- [🆕 `create` / `new`](#-create--new)
|
|
58
58
|
- [❌ `remove` / `rm` / `delete` / `del`](#-remove--rm--delete--del)
|
|
59
59
|
- [🧪 `apply`](#-apply)
|
|
60
|
+
- [🔄 `pull`](#-pull)
|
|
60
61
|
- [📤 `export`](#-export)
|
|
61
62
|
- [📥 `import`](#-import)
|
|
62
63
|
- [🔥 `wipe`](#-wipe)
|
|
@@ -77,6 +78,7 @@ Designed for developers and sysadmins, it supports pre/post hook scripts and is
|
|
|
77
78
|
- 🔄 **Git Integration** — Sync profiles with local or remote Git repositories.
|
|
78
79
|
- 📁 **Portable Configs** — Export/import profiles using `.dtsv` files for easy backups and sharing.
|
|
79
80
|
- ⚙️ **Custom Configs** — Define tracking rules via `dotctl.yaml`.
|
|
81
|
+
- 🧹 **Prune Support** — Clean stale files no longer listed in your profile with --prune.
|
|
80
82
|
|
|
81
83
|
---
|
|
82
84
|
|
|
@@ -381,7 +383,7 @@ dotctl init -c ./my_custom_config.yaml
|
|
|
381
383
|
Save current system state to the active profile.
|
|
382
384
|
|
|
383
385
|
```sh
|
|
384
|
-
dotctl save [-h] [-p <password>] [--skip-sudo] [profile]
|
|
386
|
+
dotctl save [-h] [-p <password>] [--skip-sudo] [--prune] [profile]
|
|
385
387
|
```
|
|
386
388
|
|
|
387
389
|
**Examples:**
|
|
@@ -390,12 +392,17 @@ dotctl save [-h] [-p <password>] [--skip-sudo] [profile]
|
|
|
390
392
|
dotctl save
|
|
391
393
|
dotctl save my_web_server --skip-sudo
|
|
392
394
|
dotctl save my_web_server -p mYsecretp@ssw0rd
|
|
395
|
+
dotctl save --prune
|
|
393
396
|
```
|
|
394
397
|
|
|
398
|
+
> Tip: Use --prune to clean files that were saved before but are no longer listed in the config.
|
|
399
|
+
|
|
395
400
|
**Options:**
|
|
396
401
|
|
|
397
402
|
- `--skip-sudo` – Ignore restricted resources.
|
|
398
403
|
- `-p, --password` – Password for restricted resources.
|
|
404
|
+
- `--prune` – Remove stale files from the dot repo that are no longer listed in the current `dotctl.yaml` config.
|
|
405
|
+
- `profile` – Target profile to save into (defaults to the active one if not provided)
|
|
399
406
|
|
|
400
407
|
---
|
|
401
408
|
|
|
@@ -524,6 +531,22 @@ dotctl apply MyProfile --skip-pre-hooks --ignore-hook-errors
|
|
|
524
531
|
|
|
525
532
|
---
|
|
526
533
|
|
|
534
|
+
### 🔄 `pull`
|
|
535
|
+
|
|
536
|
+
Pull the latest changes from the dotfiles repository.
|
|
537
|
+
|
|
538
|
+
```sh
|
|
539
|
+
dotctl pull [-h]
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
**Examples:**
|
|
543
|
+
|
|
544
|
+
```sh
|
|
545
|
+
dotctl pull
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
---
|
|
549
|
+
|
|
527
550
|
### 📤 `export`
|
|
528
551
|
|
|
529
552
|
Export a profile to `.dtsv`.
|
|
@@ -31,6 +31,7 @@ Designed for developers and sysadmins, it supports pre/post hook scripts and is
|
|
|
31
31
|
- [🆕 `create` / `new`](#-create--new)
|
|
32
32
|
- [❌ `remove` / `rm` / `delete` / `del`](#-remove--rm--delete--del)
|
|
33
33
|
- [🧪 `apply`](#-apply)
|
|
34
|
+
- [🔄 `pull`](#-pull)
|
|
34
35
|
- [📤 `export`](#-export)
|
|
35
36
|
- [📥 `import`](#-import)
|
|
36
37
|
- [🔥 `wipe`](#-wipe)
|
|
@@ -51,6 +52,7 @@ Designed for developers and sysadmins, it supports pre/post hook scripts and is
|
|
|
51
52
|
- 🔄 **Git Integration** — Sync profiles with local or remote Git repositories.
|
|
52
53
|
- 📁 **Portable Configs** — Export/import profiles using `.dtsv` files for easy backups and sharing.
|
|
53
54
|
- ⚙️ **Custom Configs** — Define tracking rules via `dotctl.yaml`.
|
|
55
|
+
- 🧹 **Prune Support** — Clean stale files no longer listed in your profile with --prune.
|
|
54
56
|
|
|
55
57
|
---
|
|
56
58
|
|
|
@@ -355,7 +357,7 @@ dotctl init -c ./my_custom_config.yaml
|
|
|
355
357
|
Save current system state to the active profile.
|
|
356
358
|
|
|
357
359
|
```sh
|
|
358
|
-
dotctl save [-h] [-p <password>] [--skip-sudo] [profile]
|
|
360
|
+
dotctl save [-h] [-p <password>] [--skip-sudo] [--prune] [profile]
|
|
359
361
|
```
|
|
360
362
|
|
|
361
363
|
**Examples:**
|
|
@@ -364,12 +366,17 @@ dotctl save [-h] [-p <password>] [--skip-sudo] [profile]
|
|
|
364
366
|
dotctl save
|
|
365
367
|
dotctl save my_web_server --skip-sudo
|
|
366
368
|
dotctl save my_web_server -p mYsecretp@ssw0rd
|
|
369
|
+
dotctl save --prune
|
|
367
370
|
```
|
|
368
371
|
|
|
372
|
+
> Tip: Use --prune to clean files that were saved before but are no longer listed in the config.
|
|
373
|
+
|
|
369
374
|
**Options:**
|
|
370
375
|
|
|
371
376
|
- `--skip-sudo` – Ignore restricted resources.
|
|
372
377
|
- `-p, --password` – Password for restricted resources.
|
|
378
|
+
- `--prune` – Remove stale files from the dot repo that are no longer listed in the current `dotctl.yaml` config.
|
|
379
|
+
- `profile` – Target profile to save into (defaults to the active one if not provided)
|
|
373
380
|
|
|
374
381
|
---
|
|
375
382
|
|
|
@@ -498,6 +505,22 @@ dotctl apply MyProfile --skip-pre-hooks --ignore-hook-errors
|
|
|
498
505
|
|
|
499
506
|
---
|
|
500
507
|
|
|
508
|
+
### 🔄 `pull`
|
|
509
|
+
|
|
510
|
+
Pull the latest changes from the dotfiles repository.
|
|
511
|
+
|
|
512
|
+
```sh
|
|
513
|
+
dotctl pull [-h]
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
**Examples:**
|
|
517
|
+
|
|
518
|
+
```sh
|
|
519
|
+
dotctl pull
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
---
|
|
523
|
+
|
|
501
524
|
### 📤 `export`
|
|
502
525
|
|
|
503
526
|
Export a profile to `.dtsv`.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "dotctl"
|
|
7
|
-
version = "v1.0.
|
|
7
|
+
version = "v1.0.9"
|
|
8
8
|
description = "A powerful CLI tool to profile your OS by saving, applying, exporting, and importing system configurations as named profiles. Designed to manage dot files and service configurations in a centralized Git repository (local or remote), dotctl enables seamless system replication across machines. Supports pre/post hook scripts, making it ideal for setting up servers or desktops with consistent environments."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -3,7 +3,7 @@ import socket
|
|
|
3
3
|
from datetime import datetime
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
from dotctl.utils import log
|
|
6
|
-
from dotctl.handlers.data_handler import copy
|
|
6
|
+
from dotctl.handlers.data_handler import copy, delete
|
|
7
7
|
from dotctl.paths import app_profile_directory, app_config_file
|
|
8
8
|
from dotctl.handlers.config_handler import conf_reader
|
|
9
9
|
from dotctl.handlers.git_handler import (
|
|
@@ -28,12 +28,14 @@ class SaverProps:
|
|
|
28
28
|
skip_sudo: bool
|
|
29
29
|
password: str | None
|
|
30
30
|
profile: str | None
|
|
31
|
+
prune: bool
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
saver_default_props = SaverProps(
|
|
34
35
|
skip_sudo=False,
|
|
35
36
|
password=None,
|
|
36
37
|
profile=None,
|
|
38
|
+
prune=False,
|
|
37
39
|
)
|
|
38
40
|
|
|
39
41
|
|
|
@@ -69,7 +71,11 @@ def save(props: SaverProps) -> None:
|
|
|
69
71
|
source = source_base_dir / entry
|
|
70
72
|
dest = dest_base_dir / entry
|
|
71
73
|
result = copy(
|
|
72
|
-
source,
|
|
74
|
+
source,
|
|
75
|
+
dest,
|
|
76
|
+
skip_sudo=props.skip_sudo,
|
|
77
|
+
sudo_pass=props.password,
|
|
78
|
+
prune=props.prune,
|
|
73
79
|
)
|
|
74
80
|
|
|
75
81
|
# Updated props
|
|
@@ -80,6 +86,46 @@ def save(props: SaverProps) -> None:
|
|
|
80
86
|
if sudo_pass is not None:
|
|
81
87
|
props.password = sudo_pass
|
|
82
88
|
|
|
89
|
+
# Dots Config Cleanup
|
|
90
|
+
if props.prune:
|
|
91
|
+
dot_list = [
|
|
92
|
+
p
|
|
93
|
+
for p in profile_dir.iterdir()
|
|
94
|
+
if p.is_dir() and p.name not in [".git", "hooks"]
|
|
95
|
+
]
|
|
96
|
+
for dot in dot_list:
|
|
97
|
+
if dot.name not in config.save.keys():
|
|
98
|
+
log(f'Removing "{dot.name}"...')
|
|
99
|
+
result = delete(
|
|
100
|
+
path=profile_dir / dot.name,
|
|
101
|
+
skip_sudo=props.skip_sudo,
|
|
102
|
+
sudo_pass=props.password,
|
|
103
|
+
)
|
|
104
|
+
# Updated props
|
|
105
|
+
if result is not None:
|
|
106
|
+
skip_sudo, sudo_pass = result
|
|
107
|
+
if skip_sudo is not None:
|
|
108
|
+
props.skip_sudo = skip_sudo
|
|
109
|
+
if sudo_pass is not None:
|
|
110
|
+
props.password = sudo_pass
|
|
111
|
+
else:
|
|
112
|
+
entry_list = dot.iterdir()
|
|
113
|
+
for entry in entry_list:
|
|
114
|
+
if entry.name not in config.save[dot.name].entries:
|
|
115
|
+
log(f'Removing "{dot.name}:{entry.name}"...')
|
|
116
|
+
result = delete(
|
|
117
|
+
path=profile_dir / dot.name / entry.name,
|
|
118
|
+
skip_sudo=props.skip_sudo,
|
|
119
|
+
sudo_pass=props.password,
|
|
120
|
+
)
|
|
121
|
+
# Updated props
|
|
122
|
+
if result is not None:
|
|
123
|
+
skip_sudo, sudo_pass = result
|
|
124
|
+
if skip_sudo is not None:
|
|
125
|
+
props.skip_sudo = skip_sudo
|
|
126
|
+
if sudo_pass is not None:
|
|
127
|
+
props.password = sudo_pass
|
|
128
|
+
|
|
83
129
|
add_changes(repo=repo)
|
|
84
130
|
if is_repo_changed(repo=repo):
|
|
85
131
|
hostname = socket.gethostname()
|
|
@@ -70,11 +70,17 @@ def get_parser() -> argparse.ArgumentParser:
|
|
|
70
70
|
action="store_true",
|
|
71
71
|
help="Skip all sudo operations",
|
|
72
72
|
)
|
|
73
|
+
save_parser.add_argument(
|
|
74
|
+
"--prune",
|
|
75
|
+
required=False,
|
|
76
|
+
action="store_true",
|
|
77
|
+
help="Prune all previously saved data not present in the current profile",
|
|
78
|
+
)
|
|
73
79
|
save_parser.add_argument(
|
|
74
80
|
"profile",
|
|
75
81
|
nargs="?", # Makes positional argument optional
|
|
76
82
|
type=str,
|
|
77
|
-
help="
|
|
83
|
+
help="Target profile to save into (defaults to the active one if not provided)",
|
|
78
84
|
default=None,
|
|
79
85
|
)
|
|
80
86
|
|
|
@@ -49,6 +49,35 @@ def rsync(
|
|
|
49
49
|
return stdout.strip()
|
|
50
50
|
|
|
51
51
|
|
|
52
|
+
def remove_file_or_dir(
|
|
53
|
+
location: Path,
|
|
54
|
+
sudo_pass: str | None = None,
|
|
55
|
+
):
|
|
56
|
+
command = ["rm", "-rf", str(location)]
|
|
57
|
+
if sudo_pass:
|
|
58
|
+
command = ["sshpass", "-p", sudo_pass, "sudo"] + command
|
|
59
|
+
|
|
60
|
+
process = subprocess.Popen(
|
|
61
|
+
command,
|
|
62
|
+
stdin=subprocess.PIPE,
|
|
63
|
+
stdout=subprocess.PIPE,
|
|
64
|
+
stderr=subprocess.PIPE,
|
|
65
|
+
text=True,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
stdout, stderr = process.communicate()
|
|
69
|
+
|
|
70
|
+
if process.returncode != 0:
|
|
71
|
+
log(f"cleanup failed: {stderr.strip()}")
|
|
72
|
+
|
|
73
|
+
if "Permission denied" in stderr or process.returncode == 13:
|
|
74
|
+
raise PermissionError(stdout.strip() or stderr.strip())
|
|
75
|
+
|
|
76
|
+
raise subprocess.CalledProcessError(process.returncode, command, stderr)
|
|
77
|
+
|
|
78
|
+
return stdout.strip()
|
|
79
|
+
|
|
80
|
+
|
|
52
81
|
def get_sudo_pass(path: Path, sudo_max_attempts: int = 3):
|
|
53
82
|
"""Prompt for sudo password and handle user choices."""
|
|
54
83
|
log(f"Required sudo to process {path}")
|
|
@@ -104,39 +133,66 @@ def run_command(command: str, sudo_pass: str | None = None):
|
|
|
104
133
|
return False, e.stderr.strip() if e.stderr else "", e.returncode # Failure
|
|
105
134
|
|
|
106
135
|
|
|
136
|
+
def delete(path: Path, skip_sudo=False, sudo_pass: str | None = None):
|
|
137
|
+
temp_pass = None
|
|
138
|
+
path_exists = False
|
|
139
|
+
try:
|
|
140
|
+
path_exists = path.exists()
|
|
141
|
+
except PermissionError:
|
|
142
|
+
if skip_sudo:
|
|
143
|
+
log(f"PermissionError: skipping {path}")
|
|
144
|
+
return skip_sudo, sudo_pass
|
|
145
|
+
else:
|
|
146
|
+
if not temp_pass and not sudo_pass:
|
|
147
|
+
temp_pass, sudo_pass, skip_sudo = get_sudo_pass(path)
|
|
148
|
+
success, _, _ = run_command(f"ls {path}", temp_pass or sudo_pass)
|
|
149
|
+
path_exists = success
|
|
150
|
+
|
|
151
|
+
if path_exists:
|
|
152
|
+
try:
|
|
153
|
+
remove_file_or_dir(path, temp_pass or sudo_pass)
|
|
154
|
+
except PermissionError:
|
|
155
|
+
log(f"PermissionError: {path} requires sudo access.")
|
|
156
|
+
if not skip_sudo:
|
|
157
|
+
temp_pass, sudo_pass, skip_sudo = get_sudo_pass(path)
|
|
158
|
+
if temp_pass or sudo_pass:
|
|
159
|
+
remove_file_or_dir(path, temp_pass or sudo_pass)
|
|
160
|
+
|
|
161
|
+
|
|
107
162
|
@exception_handler
|
|
108
|
-
def copy(source: Path, dest: Path, skip_sudo=False, sudo_pass=None):
|
|
163
|
+
def copy(source: Path, dest: Path, skip_sudo=False, sudo_pass=None, prune=False):
|
|
109
164
|
"""Copies files/directories using rsync and handles sudo permission issues."""
|
|
110
165
|
temp_pass = None
|
|
111
166
|
source_exists = False
|
|
112
167
|
is_dir = False # Default to file
|
|
113
168
|
|
|
114
169
|
try:
|
|
170
|
+
source_exists = source.exists()
|
|
171
|
+
is_dir = source.is_dir()
|
|
172
|
+
except PermissionError:
|
|
173
|
+
if skip_sudo:
|
|
174
|
+
log(f"PermissionError: skipping {source}")
|
|
175
|
+
return skip_sudo, sudo_pass
|
|
176
|
+
else:
|
|
177
|
+
if not temp_pass and not sudo_pass:
|
|
178
|
+
temp_pass, sudo_pass, skip_sudo = get_sudo_pass(source)
|
|
179
|
+
success, _, _ = run_command(f"ls {source}", temp_pass or sudo_pass)
|
|
180
|
+
source_exists = success
|
|
181
|
+
_, _, exit_code = run_command(f"test -d {source}", temp_pass or sudo_pass)
|
|
182
|
+
is_dir = exit_code == 0
|
|
183
|
+
if source_exists:
|
|
115
184
|
try:
|
|
116
|
-
source_exists = source.exists()
|
|
117
|
-
is_dir = source.is_dir()
|
|
118
|
-
except PermissionError:
|
|
119
|
-
if skip_sudo:
|
|
120
|
-
log(f"PermissionError: skipping {source}")
|
|
121
|
-
return skip_sudo, sudo_pass
|
|
122
|
-
else:
|
|
123
|
-
if not temp_pass and not sudo_pass:
|
|
124
|
-
temp_pass, sudo_pass, skip_sudo = get_sudo_pass(source)
|
|
125
|
-
success, _, _ = run_command(f"ls {source}", temp_pass or sudo_pass)
|
|
126
|
-
source_exists = success
|
|
127
|
-
_, _, exit_code = run_command(
|
|
128
|
-
f"test -d {source}", temp_pass or sudo_pass
|
|
129
|
-
)
|
|
130
|
-
is_dir = exit_code == 0
|
|
131
|
-
|
|
132
|
-
if source_exists:
|
|
133
185
|
assert source != dest, "Source and destination can't be the same"
|
|
134
186
|
rsync(source, dest, temp_pass or sudo_pass, is_dir=is_dir)
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
187
|
+
except PermissionError:
|
|
188
|
+
log(f"PermissionError: {source} requires sudo access.")
|
|
189
|
+
if not skip_sudo:
|
|
190
|
+
temp_pass, sudo_pass, skip_sudo = get_sudo_pass(source)
|
|
191
|
+
if temp_pass or sudo_pass:
|
|
192
|
+
rsync(source, dest, temp_pass or sudo_pass, is_dir=is_dir)
|
|
193
|
+
else:
|
|
194
|
+
if prune:
|
|
195
|
+
log(f'Removing "{dest.parent.name}:{dest.name}"...')
|
|
196
|
+
delete(dest, skip_sudo, temp_pass or sudo_pass)
|
|
141
197
|
|
|
142
198
|
return skip_sudo, sudo_pass
|
|
@@ -82,7 +82,7 @@ class DotCtl:
|
|
|
82
82
|
def save_dots(self):
|
|
83
83
|
"""Save current dotfiles."""
|
|
84
84
|
props = self._build_props(
|
|
85
|
-
saver_default_props, "skip_sudo", "password", "profile"
|
|
85
|
+
saver_default_props, "skip_sudo", "password", "profile", "prune"
|
|
86
86
|
)
|
|
87
87
|
save(props)
|
|
88
88
|
|
|
@@ -186,6 +186,7 @@ def main():
|
|
|
186
186
|
"details": getattr(args, "details", False),
|
|
187
187
|
"fetch": getattr(args, "fetch", False),
|
|
188
188
|
"no_confirm": getattr(args, "no_confirm", False),
|
|
189
|
+
"prune": getattr(args, "prune", False),
|
|
189
190
|
}
|
|
190
191
|
|
|
191
192
|
dot_ctl_obj = DotCtl(**common_args)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dotctl
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.9
|
|
4
4
|
Summary: A powerful CLI tool to profile your OS by saving, applying, exporting, and importing system configurations as named profiles. Designed to manage dot files and service configurations in a centralized Git repository (local or remote), dotctl enables seamless system replication across machines. Supports pre/post hook scripts, making it ideal for setting up servers or desktops with consistent environments.
|
|
5
5
|
Author-email: Pankaj Jackson <pankajackson@live.co.uk>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -57,6 +57,7 @@ Designed for developers and sysadmins, it supports pre/post hook scripts and is
|
|
|
57
57
|
- [🆕 `create` / `new`](#-create--new)
|
|
58
58
|
- [❌ `remove` / `rm` / `delete` / `del`](#-remove--rm--delete--del)
|
|
59
59
|
- [🧪 `apply`](#-apply)
|
|
60
|
+
- [🔄 `pull`](#-pull)
|
|
60
61
|
- [📤 `export`](#-export)
|
|
61
62
|
- [📥 `import`](#-import)
|
|
62
63
|
- [🔥 `wipe`](#-wipe)
|
|
@@ -77,6 +78,7 @@ Designed for developers and sysadmins, it supports pre/post hook scripts and is
|
|
|
77
78
|
- 🔄 **Git Integration** — Sync profiles with local or remote Git repositories.
|
|
78
79
|
- 📁 **Portable Configs** — Export/import profiles using `.dtsv` files for easy backups and sharing.
|
|
79
80
|
- ⚙️ **Custom Configs** — Define tracking rules via `dotctl.yaml`.
|
|
81
|
+
- 🧹 **Prune Support** — Clean stale files no longer listed in your profile with --prune.
|
|
80
82
|
|
|
81
83
|
---
|
|
82
84
|
|
|
@@ -381,7 +383,7 @@ dotctl init -c ./my_custom_config.yaml
|
|
|
381
383
|
Save current system state to the active profile.
|
|
382
384
|
|
|
383
385
|
```sh
|
|
384
|
-
dotctl save [-h] [-p <password>] [--skip-sudo] [profile]
|
|
386
|
+
dotctl save [-h] [-p <password>] [--skip-sudo] [--prune] [profile]
|
|
385
387
|
```
|
|
386
388
|
|
|
387
389
|
**Examples:**
|
|
@@ -390,12 +392,17 @@ dotctl save [-h] [-p <password>] [--skip-sudo] [profile]
|
|
|
390
392
|
dotctl save
|
|
391
393
|
dotctl save my_web_server --skip-sudo
|
|
392
394
|
dotctl save my_web_server -p mYsecretp@ssw0rd
|
|
395
|
+
dotctl save --prune
|
|
393
396
|
```
|
|
394
397
|
|
|
398
|
+
> Tip: Use --prune to clean files that were saved before but are no longer listed in the config.
|
|
399
|
+
|
|
395
400
|
**Options:**
|
|
396
401
|
|
|
397
402
|
- `--skip-sudo` – Ignore restricted resources.
|
|
398
403
|
- `-p, --password` – Password for restricted resources.
|
|
404
|
+
- `--prune` – Remove stale files from the dot repo that are no longer listed in the current `dotctl.yaml` config.
|
|
405
|
+
- `profile` – Target profile to save into (defaults to the active one if not provided)
|
|
399
406
|
|
|
400
407
|
---
|
|
401
408
|
|
|
@@ -524,6 +531,22 @@ dotctl apply MyProfile --skip-pre-hooks --ignore-hook-errors
|
|
|
524
531
|
|
|
525
532
|
---
|
|
526
533
|
|
|
534
|
+
### 🔄 `pull`
|
|
535
|
+
|
|
536
|
+
Pull the latest changes from the dotfiles repository.
|
|
537
|
+
|
|
538
|
+
```sh
|
|
539
|
+
dotctl pull [-h]
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
**Examples:**
|
|
543
|
+
|
|
544
|
+
```sh
|
|
545
|
+
dotctl pull
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
---
|
|
549
|
+
|
|
527
550
|
### 📤 `export`
|
|
528
551
|
|
|
529
552
|
Export a profile to `.dtsv`.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|