dotctl 0.0.1__tar.gz → 1.0.2__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.
Files changed (43) hide show
  1. dotctl-1.0.2/LICENSE +21 -0
  2. dotctl-1.0.2/PKG-INFO +239 -0
  3. dotctl-1.0.2/README.md +191 -0
  4. dotctl-1.0.2/pyproject.toml +27 -0
  5. dotctl-1.0.2/src/dotctl/__init__.py +12 -0
  6. dotctl-1.0.2/src/dotctl/actions/activator.py +70 -0
  7. dotctl-1.0.2/src/dotctl/actions/creator.py +47 -0
  8. dotctl-1.0.2/src/dotctl/actions/exporter.py +111 -0
  9. dotctl-1.0.2/src/dotctl/actions/importer.py +123 -0
  10. dotctl-1.0.2/src/dotctl/actions/initializer.py +64 -0
  11. dotctl-1.0.2/src/dotctl/actions/lister.py +198 -0
  12. dotctl-1.0.2/src/dotctl/actions/remover.py +84 -0
  13. dotctl-1.0.2/src/dotctl/actions/saver.py +97 -0
  14. dotctl-1.0.2/src/dotctl/actions/switcher.py +73 -0
  15. dotctl-1.0.2/src/dotctl/arg_manager.py +229 -0
  16. dotctl-1.0.2/src/dotctl/exception.py +32 -0
  17. dotctl-1.0.2/src/dotctl/handlers/__init__.py +0 -0
  18. dotctl-1.0.2/src/dotctl/handlers/config_handler.py +154 -0
  19. dotctl-1.0.2/src/dotctl/handlers/data_handler.py +142 -0
  20. dotctl-1.0.2/src/dotctl/handlers/git_handler.py +257 -0
  21. dotctl-1.0.2/src/dotctl/main.py +264 -0
  22. dotctl-1.0.2/src/dotctl/paths.py +17 -0
  23. dotctl-1.0.2/src/dotctl/utils.py +5 -0
  24. dotctl-1.0.2/src/dotctl/validators.py +45 -0
  25. dotctl-1.0.2/src/dotctl.egg-info/PKG-INFO +239 -0
  26. dotctl-1.0.2/src/dotctl.egg-info/SOURCES.txt +31 -0
  27. dotctl-1.0.2/src/dotctl.egg-info/entry_points.txt +2 -0
  28. dotctl-1.0.2/src/dotctl.egg-info/requires.txt +2 -0
  29. dotctl-1.0.2/src/dotctl.egg-info/top_level.txt +2 -0
  30. dotctl-1.0.2/src/plasmasaver/__init__.py +0 -0
  31. dotctl-0.0.1/LICENSE +0 -674
  32. dotctl-0.0.1/PKG-INFO +0 -800
  33. dotctl-0.0.1/README.md +0 -106
  34. dotctl-0.0.1/pyproject.toml +0 -31
  35. dotctl-0.0.1/src/dotctl/dotctl.py +0 -964
  36. dotctl-0.0.1/src/dotctl.egg-info/PKG-INFO +0 -800
  37. dotctl-0.0.1/src/dotctl.egg-info/SOURCES.txt +0 -11
  38. dotctl-0.0.1/src/dotctl.egg-info/entry_points.txt +0 -2
  39. dotctl-0.0.1/src/dotctl.egg-info/requires.txt +0 -1
  40. dotctl-0.0.1/src/dotctl.egg-info/top_level.txt +0 -1
  41. {dotctl-0.0.1 → dotctl-1.0.2}/setup.cfg +0 -0
  42. {dotctl-0.0.1/src/dotctl → dotctl-1.0.2/src/dotctl/actions}/__init__.py +0 -0
  43. {dotctl-0.0.1 → dotctl-1.0.2}/src/dotctl.egg-info/dependency_links.txt +0 -0
dotctl-1.0.2/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Pankaj Kumar Patel
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
dotctl-1.0.2/PKG-INFO ADDED
@@ -0,0 +1,239 @@
1
+ Metadata-Version: 2.4
2
+ Name: dotctl
3
+ Version: 1.0.2
4
+ Summary: Command Line Interface to manage (save, export, import) dot files in the form of profiles.
5
+ Author-email: Pankaj Jackson <pankajackson@live.co.uk>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 Pankaj Kumar Patel
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/pankajackson/dotctl
29
+ Project-URL: Bug Tracker, https://github.com/pankajackson/dotctl/issues
30
+ Project-URL: Source, https://github.com/pankajackson/dotctl
31
+ Keywords: dotfiles,config,settings,backup,dotfile-manager
32
+ Classifier: Programming Language :: Python :: 3
33
+ Classifier: Programming Language :: Python :: 3.10
34
+ Classifier: Programming Language :: Python :: 3.11
35
+ Classifier: Programming Language :: Python :: 3.12
36
+ Classifier: Development Status :: 3 - Alpha
37
+ Classifier: Intended Audience :: End Users/Desktop
38
+ Classifier: License :: OSI Approved :: MIT License
39
+ Classifier: Operating System :: POSIX :: Linux
40
+ Classifier: Topic :: System :: Archiving :: Backup
41
+ Classifier: Topic :: Utilities
42
+ Requires-Python: >=3.10
43
+ Description-Content-Type: text/markdown
44
+ License-File: LICENSE
45
+ Requires-Dist: PyYAML
46
+ Requires-Dist: gitpython
47
+ Dynamic: license-file
48
+
49
+ # DotCtl
50
+
51
+ A CLI Tool to Manage DOT Files/Settings/Configurations.
52
+
53
+ ## Features
54
+
55
+ - Save Profile: Save existing dot files/config/settings.
56
+ - Import Profile: Import existing dot files/config/settings from a `.plsv` file.
57
+ - Export Profile: Export and share existing dot files/config/settings to a `.plsv` file.
58
+ - Manage multiple profiles with ease.
59
+
60
+ ## Installation
61
+
62
+ ```sh
63
+ pip install dotctl
64
+ ```
65
+
66
+ ## CLI Guide
67
+
68
+ ### Save Profile
69
+
70
+ ```sh
71
+ dotctl save <profile_name>
72
+ ```
73
+
74
+ **Example:**
75
+
76
+ ```sh
77
+ dotctl save MyProfile
78
+ ```
79
+
80
+ **Options:**
81
+
82
+ - `-f, --force` → Overwrite already saved profiles.
83
+ - `-c <path>, --config-file <path>` → Use external config file.
84
+ - `-e <env>, --env <env>` → Desktop environment (e.g., KDE).
85
+ - `-p <password>, --password <password>` → Sudo Password to authorize restricted data (e.g., `/usr/share`).
86
+ - `--include-global` → Include data from the global data directory (`/usr/share`).
87
+ - `--include-sddm` → Include SDDM data/configs (`/usr/share/sddm`, `/etc/sddm.conf.d`).
88
+ - `--sddm-only` → Operate only on SDDM configurations (**Note:** Requires sudo password).
89
+ - `--skip-sudo` → Skip all sudo operations.
90
+
91
+ ### Remove Profile
92
+
93
+ ```sh
94
+ dotctl remove <profile_name>
95
+ ```
96
+
97
+ **Example:**
98
+
99
+ ```sh
100
+ dotctl remove MyProfile
101
+ ```
102
+
103
+ ### List Profiles
104
+
105
+ ```sh
106
+ dotctl list
107
+ ```
108
+
109
+ ### Apply Profile
110
+
111
+ ```sh
112
+ dotctl apply <profile_name>
113
+ ```
114
+
115
+ **Example:**
116
+
117
+ ```sh
118
+ dotctl apply MyProfile
119
+ ```
120
+
121
+ **Options:**
122
+
123
+ - `-p <password>, --password <password>` → Sudo Password for restricted data.
124
+ - `--sddm-only` → Apply only SDDM configurations (**Requires sudo password**).
125
+ - `--skip-global` → Skip data from the global directory (`/usr/share`).
126
+ - `--skip-sddm` → Skip SDDM configurations.
127
+ - `--skip-sudo` → Skip all sudo operations.
128
+
129
+ ### Import Profile
130
+
131
+ ```sh
132
+ dotctl import <profile_path>
133
+ ```
134
+
135
+ **Example:**
136
+
137
+ ```sh
138
+ dotctl import MyProfile.plsv
139
+ ```
140
+
141
+ **Options:**
142
+
143
+ - `-p <password>, --password <password>` → Sudo Password for restricted data.
144
+ - `--config-only` → Apply only dot files/configurations (`~/.config`).
145
+ - `--data-only` → Apply only dot files/data (`~/.local/share`).
146
+ - `--sddm-only` → Apply only SDDM configurations (**Requires sudo password**).
147
+ - `--skip-global` → Skip global data.
148
+ - `--skip-sddm` → Skip SDDM configurations.
149
+ - `--skip-sudo` → Skip all sudo operations.
150
+
151
+ ### Export Profile
152
+
153
+ ```sh
154
+ dotctl export <profile_path>
155
+ ```
156
+
157
+ **Example:**
158
+
159
+ ```sh
160
+ dotctl export MyProfile.plsv
161
+ ```
162
+
163
+ **Options:**
164
+
165
+ - `-p <password>, --password <password>` → Sudo Password for restricted data.
166
+ - `--config-only` → Export only dot files/configurations.
167
+ - `--data-only` → Export only dot files/data.
168
+ - `--sddm-only` → Export only SDDM configurations (**Requires sudo password**).
169
+ - `--skip-global` → Skip global data.
170
+ - `--skip-sddm` → Skip SDDM configurations.
171
+ - `--skip-sudo` → Skip all sudo operations.
172
+
173
+ ### Wipe All Profiles
174
+
175
+ ```sh
176
+ dotctl wipe
177
+ ```
178
+
179
+ ### Help
180
+
181
+ ```sh
182
+ dotctl -h
183
+ dotctl <action> -h
184
+ ```
185
+
186
+ **Example:**
187
+
188
+ ```sh
189
+ dotctl import -h
190
+ ```
191
+
192
+ ### Version
193
+
194
+ ```sh
195
+ dotctl -v
196
+ ```
197
+
198
+ ---
199
+
200
+ ## Development & Publishing Guide
201
+
202
+ ### Setup Development Environment
203
+
204
+ ```sh
205
+ # Create virtual environment (optional but recommended)
206
+ python -m venv venv
207
+ source venv/bin/activate # On Linux/macOS
208
+ venv\Scripts\activate # On Windows
209
+
210
+ # Install dependencies
211
+ pip install -r requirements.txt
212
+ ```
213
+
214
+ ### Build the Package
215
+
216
+ ```sh
217
+ python -m build
218
+ ```
219
+
220
+ This will generate a `dist/` directory with `.tar.gz` and `.whl` files.
221
+
222
+ ### Publish to TestPyPI
223
+
224
+ ```sh
225
+ twine upload --repository testpypi dist/*
226
+ ```
227
+
228
+ ### Publish to PyPI
229
+
230
+ ```sh
231
+ twine upload --repository pypi dist/*
232
+ ```
233
+
234
+ ---
235
+
236
+ ## Who do I talk to?
237
+
238
+ - **Repo Owner/Admin:** Pankaj Jackson
239
+ - **Community Support:** Reach out via GitHub Issues
dotctl-1.0.2/README.md ADDED
@@ -0,0 +1,191 @@
1
+ # DotCtl
2
+
3
+ A CLI Tool to Manage DOT Files/Settings/Configurations.
4
+
5
+ ## Features
6
+
7
+ - Save Profile: Save existing dot files/config/settings.
8
+ - Import Profile: Import existing dot files/config/settings from a `.plsv` file.
9
+ - Export Profile: Export and share existing dot files/config/settings to a `.plsv` file.
10
+ - Manage multiple profiles with ease.
11
+
12
+ ## Installation
13
+
14
+ ```sh
15
+ pip install dotctl
16
+ ```
17
+
18
+ ## CLI Guide
19
+
20
+ ### Save Profile
21
+
22
+ ```sh
23
+ dotctl save <profile_name>
24
+ ```
25
+
26
+ **Example:**
27
+
28
+ ```sh
29
+ dotctl save MyProfile
30
+ ```
31
+
32
+ **Options:**
33
+
34
+ - `-f, --force` → Overwrite already saved profiles.
35
+ - `-c <path>, --config-file <path>` → Use external config file.
36
+ - `-e <env>, --env <env>` → Desktop environment (e.g., KDE).
37
+ - `-p <password>, --password <password>` → Sudo Password to authorize restricted data (e.g., `/usr/share`).
38
+ - `--include-global` → Include data from the global data directory (`/usr/share`).
39
+ - `--include-sddm` → Include SDDM data/configs (`/usr/share/sddm`, `/etc/sddm.conf.d`).
40
+ - `--sddm-only` → Operate only on SDDM configurations (**Note:** Requires sudo password).
41
+ - `--skip-sudo` → Skip all sudo operations.
42
+
43
+ ### Remove Profile
44
+
45
+ ```sh
46
+ dotctl remove <profile_name>
47
+ ```
48
+
49
+ **Example:**
50
+
51
+ ```sh
52
+ dotctl remove MyProfile
53
+ ```
54
+
55
+ ### List Profiles
56
+
57
+ ```sh
58
+ dotctl list
59
+ ```
60
+
61
+ ### Apply Profile
62
+
63
+ ```sh
64
+ dotctl apply <profile_name>
65
+ ```
66
+
67
+ **Example:**
68
+
69
+ ```sh
70
+ dotctl apply MyProfile
71
+ ```
72
+
73
+ **Options:**
74
+
75
+ - `-p <password>, --password <password>` → Sudo Password for restricted data.
76
+ - `--sddm-only` → Apply only SDDM configurations (**Requires sudo password**).
77
+ - `--skip-global` → Skip data from the global directory (`/usr/share`).
78
+ - `--skip-sddm` → Skip SDDM configurations.
79
+ - `--skip-sudo` → Skip all sudo operations.
80
+
81
+ ### Import Profile
82
+
83
+ ```sh
84
+ dotctl import <profile_path>
85
+ ```
86
+
87
+ **Example:**
88
+
89
+ ```sh
90
+ dotctl import MyProfile.plsv
91
+ ```
92
+
93
+ **Options:**
94
+
95
+ - `-p <password>, --password <password>` → Sudo Password for restricted data.
96
+ - `--config-only` → Apply only dot files/configurations (`~/.config`).
97
+ - `--data-only` → Apply only dot files/data (`~/.local/share`).
98
+ - `--sddm-only` → Apply only SDDM configurations (**Requires sudo password**).
99
+ - `--skip-global` → Skip global data.
100
+ - `--skip-sddm` → Skip SDDM configurations.
101
+ - `--skip-sudo` → Skip all sudo operations.
102
+
103
+ ### Export Profile
104
+
105
+ ```sh
106
+ dotctl export <profile_path>
107
+ ```
108
+
109
+ **Example:**
110
+
111
+ ```sh
112
+ dotctl export MyProfile.plsv
113
+ ```
114
+
115
+ **Options:**
116
+
117
+ - `-p <password>, --password <password>` → Sudo Password for restricted data.
118
+ - `--config-only` → Export only dot files/configurations.
119
+ - `--data-only` → Export only dot files/data.
120
+ - `--sddm-only` → Export only SDDM configurations (**Requires sudo password**).
121
+ - `--skip-global` → Skip global data.
122
+ - `--skip-sddm` → Skip SDDM configurations.
123
+ - `--skip-sudo` → Skip all sudo operations.
124
+
125
+ ### Wipe All Profiles
126
+
127
+ ```sh
128
+ dotctl wipe
129
+ ```
130
+
131
+ ### Help
132
+
133
+ ```sh
134
+ dotctl -h
135
+ dotctl <action> -h
136
+ ```
137
+
138
+ **Example:**
139
+
140
+ ```sh
141
+ dotctl import -h
142
+ ```
143
+
144
+ ### Version
145
+
146
+ ```sh
147
+ dotctl -v
148
+ ```
149
+
150
+ ---
151
+
152
+ ## Development & Publishing Guide
153
+
154
+ ### Setup Development Environment
155
+
156
+ ```sh
157
+ # Create virtual environment (optional but recommended)
158
+ python -m venv venv
159
+ source venv/bin/activate # On Linux/macOS
160
+ venv\Scripts\activate # On Windows
161
+
162
+ # Install dependencies
163
+ pip install -r requirements.txt
164
+ ```
165
+
166
+ ### Build the Package
167
+
168
+ ```sh
169
+ python -m build
170
+ ```
171
+
172
+ This will generate a `dist/` directory with `.tar.gz` and `.whl` files.
173
+
174
+ ### Publish to TestPyPI
175
+
176
+ ```sh
177
+ twine upload --repository testpypi dist/*
178
+ ```
179
+
180
+ ### Publish to PyPI
181
+
182
+ ```sh
183
+ twine upload --repository pypi dist/*
184
+ ```
185
+
186
+ ---
187
+
188
+ ## Who do I talk to?
189
+
190
+ - **Repo Owner/Admin:** Pankaj Jackson
191
+ - **Community Support:** Reach out via GitHub Issues
@@ -0,0 +1,27 @@
1
+ [build-system]
2
+ requires = [ "setuptools>=61.0", "wheel",]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "dotctl"
7
+ version = "v1.0.2"
8
+ description = "Command Line Interface to manage (save, export, import) dot files in the form of profiles."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ dependencies = [ "PyYAML", "gitpython",]
12
+ keywords = [ "dotfiles", "config", "settings", "backup", "dotfile-manager",]
13
+ classifiers = [ "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Development Status :: 3 - Alpha", "Intended Audience :: End Users/Desktop", "License :: OSI Approved :: MIT License", "Operating System :: POSIX :: Linux", "Topic :: System :: Archiving :: Backup", "Topic :: Utilities",]
14
+ [[project.authors]]
15
+ name = "Pankaj Jackson"
16
+ email = "pankajackson@live.co.uk"
17
+
18
+ [project.license]
19
+ file = "LICENSE"
20
+
21
+ [project.scripts]
22
+ dotctl = "dotctl.main:main"
23
+
24
+ [project.urls]
25
+ Homepage = "https://github.com/pankajackson/dotctl"
26
+ "Bug Tracker" = "https://github.com/pankajackson/dotctl/issues"
27
+ Source = "https://github.com/pankajackson/dotctl"
@@ -0,0 +1,12 @@
1
+ from importlib.metadata import version as pkg_version, PackageNotFoundError
2
+ import os
3
+
4
+ __APP_NAME__ = "dotctl"
5
+ try:
6
+ __APP_VERSION__ = pkg_version("dotctl")
7
+ except PackageNotFoundError:
8
+ __APP_VERSION__ = "0.0.0"
9
+ __BASE_DIR__ = os.path.dirname(os.path.abspath(__file__))
10
+ __DEFAULT_PROFILE__ = "default"
11
+ __EXPORT_EXTENSION__ = ".dtsv"
12
+ __EXPORT_DATA_DIR__ = "._export_"
@@ -0,0 +1,70 @@
1
+ from pathlib import Path
2
+ from dataclasses import dataclass
3
+ from dotctl.utils import log
4
+ from dotctl.handlers.data_handler import copy
5
+ from dotctl.paths import app_profile_directory, app_config_file
6
+ from dotctl.handlers.config_handler import conf_reader
7
+ from dotctl.handlers.git_handler import (
8
+ get_repo,
9
+ get_repo_branches,
10
+ git_fetch,
11
+ checkout_branch,
12
+ )
13
+ from dotctl.exception import exception_handler
14
+
15
+
16
+ @dataclass
17
+ class ActivatorProps:
18
+ skip_sudo: bool
19
+ password: str | None
20
+ profile: str | None
21
+
22
+
23
+ activator_default_props = ActivatorProps(
24
+ skip_sudo=False,
25
+ password=None,
26
+ profile=None,
27
+ )
28
+
29
+
30
+ @exception_handler
31
+ def apply(props: ActivatorProps) -> None:
32
+ log("Activating profile...")
33
+ profile_dir = Path(app_profile_directory)
34
+ profile = props.profile
35
+ repo = get_repo(profile_dir)
36
+
37
+ _, _, active_profile, all_profiles = get_repo_branches(repo)
38
+ if profile is not None and active_profile != profile:
39
+ if profile not in all_profiles:
40
+ git_fetch(repo)
41
+ if profile in all_profiles:
42
+ checkout_branch(repo, profile)
43
+ log(f"Switched to profile: {profile}")
44
+ else:
45
+ log(f"Profile {profile} is not available.")
46
+ return
47
+
48
+ config = conf_reader(config_file=Path(app_config_file))
49
+
50
+ for name, section in config.save.items():
51
+ source_base_dir = profile_dir / name
52
+ dest_base_dir = Path(section.location)
53
+ dest_base_dir.mkdir(exist_ok=True)
54
+ log(f'Applying "{name}"...')
55
+ for entry in section.entries:
56
+ source = source_base_dir / entry
57
+ dest = dest_base_dir / entry
58
+ result = copy(
59
+ source, dest, skip_sudo=props.skip_sudo, sudo_pass=props.password
60
+ )
61
+
62
+ # Updated props
63
+ if result is not None:
64
+ skip_sudo, sudo_pass = result
65
+ if skip_sudo is not None:
66
+ props.skip_sudo = skip_sudo
67
+ if sudo_pass is not None:
68
+ props.password = sudo_pass
69
+
70
+ log("Profile saved successfully!")
@@ -0,0 +1,47 @@
1
+ import sys
2
+ from pathlib import Path
3
+ from dataclasses import dataclass
4
+ from git import Repo, GitCommandError, InvalidGitRepositoryError
5
+ from dotctl.paths import app_profile_directory
6
+ from dotctl.utils import log
7
+ from dotctl.exception import exception_handler
8
+ from dotctl.handlers.git_handler import (
9
+ get_repo,
10
+ get_repo_branches,
11
+ git_fetch,
12
+ create_branch,
13
+ )
14
+ from dotctl import __APP_NAME__, __DEFAULT_PROFILE__
15
+
16
+
17
+ @dataclass
18
+ class CreatorProps:
19
+ profile: str
20
+ profile_dir: Path
21
+ fetch: bool
22
+
23
+
24
+ creator_default_props = CreatorProps(
25
+ profile=__DEFAULT_PROFILE__,
26
+ profile_dir=Path(app_profile_directory),
27
+ fetch=False,
28
+ )
29
+
30
+
31
+ @exception_handler
32
+ def create(props: CreatorProps):
33
+ log("Creating profile...")
34
+ repo = get_repo(props.profile_dir)
35
+
36
+ try:
37
+ if props.fetch:
38
+ git_fetch(repo)
39
+
40
+ _, _, _, all_profiles = get_repo_branches(repo)
41
+ if props.profile in all_profiles:
42
+ log(f"Profile '{props.profile}' already exists.")
43
+ return
44
+ create_branch(repo, props.profile)
45
+ log(f"Profile '{props.profile}' created and activated successfully.")
46
+ except Exception as e:
47
+ raise Exception(f"Unexpected error: {e}")