kctl-dokploy 0.5.0__py3-none-any.whl
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.
- kctl_dokploy/SKILL.extra.md +50 -0
- kctl_dokploy/__init__.py +3 -0
- kctl_dokploy/__main__.py +5 -0
- kctl_dokploy/cli.py +270 -0
- kctl_dokploy/commands/__init__.py +0 -0
- kctl_dokploy/commands/aliases.py +94 -0
- kctl_dokploy/commands/applications.py +339 -0
- kctl_dokploy/commands/audit.py +488 -0
- kctl_dokploy/commands/autodeploy.py +212 -0
- kctl_dokploy/commands/backups.py +601 -0
- kctl_dokploy/commands/backups_flow.py +423 -0
- kctl_dokploy/commands/backups_pull.py +814 -0
- kctl_dokploy/commands/backups_restore.py +389 -0
- kctl_dokploy/commands/bulk.py +331 -0
- kctl_dokploy/commands/certificates.py +154 -0
- kctl_dokploy/commands/cluster.py +178 -0
- kctl_dokploy/commands/compose.py +659 -0
- kctl_dokploy/commands/config_cmd.py +150 -0
- kctl_dokploy/commands/dashboard.py +157 -0
- kctl_dokploy/commands/databases.py +378 -0
- kctl_dokploy/commands/deploy.py +843 -0
- kctl_dokploy/commands/deployments.py +324 -0
- kctl_dokploy/commands/diagnose.py +986 -0
- kctl_dokploy/commands/docker.py +172 -0
- kctl_dokploy/commands/doctor_cmd.py +82 -0
- kctl_dokploy/commands/domains.py +211 -0
- kctl_dokploy/commands/env.py +208 -0
- kctl_dokploy/commands/environments.py +167 -0
- kctl_dokploy/commands/git.py +218 -0
- kctl_dokploy/commands/maintenance.py +510 -0
- kctl_dokploy/commands/migrate.py +150 -0
- kctl_dokploy/commands/monitoring.py +182 -0
- kctl_dokploy/commands/mounts.py +151 -0
- kctl_dokploy/commands/notifications.py +239 -0
- kctl_dokploy/commands/patches.py +260 -0
- kctl_dokploy/commands/pipeline.py +570 -0
- kctl_dokploy/commands/ports.py +109 -0
- kctl_dokploy/commands/projects.py +162 -0
- kctl_dokploy/commands/redirects.py +105 -0
- kctl_dokploy/commands/registry.py +146 -0
- kctl_dokploy/commands/report.py +533 -0
- kctl_dokploy/commands/schedules.py +172 -0
- kctl_dokploy/commands/security_cmd.py +96 -0
- kctl_dokploy/commands/servers.py +345 -0
- kctl_dokploy/commands/settings.py +184 -0
- kctl_dokploy/commands/setup.py +760 -0
- kctl_dokploy/commands/skill_cmd.py +76 -0
- kctl_dokploy/commands/status.py +25 -0
- kctl_dokploy/commands/template.py +414 -0
- kctl_dokploy/commands/users.py +163 -0
- kctl_dokploy/commands/volume_backups.py +237 -0
- kctl_dokploy/core/__init__.py +0 -0
- kctl_dokploy/core/async_client.py +27 -0
- kctl_dokploy/core/callbacks.py +39 -0
- kctl_dokploy/core/client.py +58 -0
- kctl_dokploy/core/config.py +134 -0
- kctl_dokploy/core/deploy_ops.py +535 -0
- kctl_dokploy/core/deploy_validators.py +455 -0
- kctl_dokploy/core/deployer.py +1315 -0
- kctl_dokploy/core/exceptions.py +56 -0
- kctl_dokploy/core/health_ops.py +158 -0
- kctl_dokploy/core/helpers.py +122 -0
- kctl_dokploy/core/lan_ip.py +51 -0
- kctl_dokploy/core/local_reconciler.py +315 -0
- kctl_dokploy/core/manifest.py +399 -0
- kctl_dokploy/core/migration_manifest.py +87 -0
- kctl_dokploy/core/migrator.py +515 -0
- kctl_dokploy/core/notify_ops.py +306 -0
- kctl_dokploy/core/output.py +8 -0
- kctl_dokploy/core/plugins.py +57 -0
- kctl_dokploy/core/preflight.py +495 -0
- kctl_dokploy/core/resolve.py +146 -0
- kctl_dokploy/core/troubleshoot.py +472 -0
- kctl_dokploy/core/utils.py +93 -0
- kctl_dokploy/core/validators.py +225 -0
- kctl_dokploy-0.5.0.dist-info/METADATA +18 -0
- kctl_dokploy-0.5.0.dist-info/RECORD +79 -0
- kctl_dokploy-0.5.0.dist-info/WHEEL +4 -0
- kctl_dokploy-0.5.0.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
## Troubleshooting Workflow
|
|
2
|
+
|
|
3
|
+
When a deployment fails, use this exact flow:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
# Step 1: Auto-diagnose (shows error type, container logs, suggestions)
|
|
7
|
+
kctl-dokploy deploy troubleshoot -f <manifest>
|
|
8
|
+
|
|
9
|
+
# Step 2: If you need more detail on containers
|
|
10
|
+
kctl-dokploy compose service-logs <compose-id> --service <name> --tail 200
|
|
11
|
+
|
|
12
|
+
# Step 3: If you need build/deployment logs
|
|
13
|
+
kctl-dokploy deployments logs --compose <compose-id>
|
|
14
|
+
|
|
15
|
+
# Step 4: If service is on remote server, list its containers
|
|
16
|
+
kctl-dokploy docker containers --server <server-name>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Pre-Deploy Validation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Single manifest
|
|
23
|
+
kctl-dokploy deploy preflight -f <manifest>
|
|
24
|
+
|
|
25
|
+
# Specific gates only
|
|
26
|
+
kctl-dokploy deploy preflight -f <manifest> --gates dns,env_sync,compose_assignment
|
|
27
|
+
|
|
28
|
+
# All manifests for a server
|
|
29
|
+
kctl-dokploy deploy preflight-all -d deploys/instances/production/ --server mac-prod-01
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Server Migration
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
kctl-dokploy deploy migrate validate -f deploys/migrations/<manifest>.yaml
|
|
36
|
+
kctl-dokploy deploy migrate plan -f deploys/migrations/<manifest>.yaml
|
|
37
|
+
kctl-dokploy deploy migrate apply -f deploys/migrations/<manifest>.yaml
|
|
38
|
+
kctl-dokploy deploy migrate apply -f deploys/migrations/<manifest>.yaml --resume
|
|
39
|
+
kctl-dokploy deploy migrate rollback -f deploys/migrations/<manifest>.yaml
|
|
40
|
+
kctl-dokploy deploy migrate cleanup -f deploys/migrations/<manifest>.yaml
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Critical Rules
|
|
44
|
+
|
|
45
|
+
1. **NEVER deploy ad-hoc** — always use manifest system at `deploys/`
|
|
46
|
+
2. **NEVER use raw SSH** — use `kctl-dokploy compose service-logs` or `docker containers --server`
|
|
47
|
+
3. **domain.service MUST match** service name in docker-compose.yml
|
|
48
|
+
4. **Run preflight before deploy** — `deploy apply` does this automatically
|
|
49
|
+
5. **env_file is source of truth** — env_overrides should NOT duplicate or wipe env_file values
|
|
50
|
+
6. **Global option --json goes BEFORE the command group** — e.g., `kctl-dokploy --json compose list`
|
kctl_dokploy/__init__.py
ADDED
kctl_dokploy/__main__.py
ADDED
kctl_dokploy/cli.py
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"""Main CLI entry point for kctl-dokploy."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Annotated
|
|
6
|
+
|
|
7
|
+
import typer
|
|
8
|
+
from kctl_lib import KctlError, handle_cli_error
|
|
9
|
+
|
|
10
|
+
from kctl_dokploy import __version__
|
|
11
|
+
from kctl_dokploy.commands.aliases import register_aliases
|
|
12
|
+
from kctl_dokploy.commands.applications import app as applications_app
|
|
13
|
+
from kctl_dokploy.commands.audit import app as audit_app
|
|
14
|
+
from kctl_dokploy.commands.autodeploy import app as autodeploy_app
|
|
15
|
+
from kctl_dokploy.commands.backups import app as backups_app
|
|
16
|
+
from kctl_dokploy.commands.bulk import app as bulk_app
|
|
17
|
+
from kctl_dokploy.commands.certificates import app as certificates_app
|
|
18
|
+
from kctl_dokploy.commands.cluster import app as cluster_app
|
|
19
|
+
from kctl_dokploy.commands.compose import app as compose_app
|
|
20
|
+
from kctl_dokploy.commands.config_cmd import app as config_app
|
|
21
|
+
from kctl_dokploy.commands.dashboard import app as dashboard_app
|
|
22
|
+
from kctl_dokploy.commands.databases import app as databases_app
|
|
23
|
+
from kctl_dokploy.commands.deployments import app as deployments_app
|
|
24
|
+
from kctl_dokploy.commands.diagnose import app as diagnose_app
|
|
25
|
+
from kctl_dokploy.commands.docker import app as docker_app
|
|
26
|
+
from kctl_dokploy.commands.domains import app as domains_app
|
|
27
|
+
from kctl_dokploy.commands.env import app as env_app
|
|
28
|
+
from kctl_dokploy.commands.environments import app as environments_app
|
|
29
|
+
from kctl_dokploy.commands.git import app as git_app
|
|
30
|
+
from kctl_dokploy.commands.maintenance import app as maintenance_app
|
|
31
|
+
from kctl_dokploy.commands.monitoring import app as monitoring_app
|
|
32
|
+
from kctl_dokploy.commands.mounts import app as mounts_app
|
|
33
|
+
from kctl_dokploy.commands.notifications import app as notifications_app
|
|
34
|
+
from kctl_dokploy.commands.pipeline import app as pipeline_app
|
|
35
|
+
from kctl_dokploy.commands.ports import app as ports_app
|
|
36
|
+
from kctl_dokploy.commands.projects import app as projects_app
|
|
37
|
+
from kctl_dokploy.commands.redirects import app as redirects_app
|
|
38
|
+
from kctl_dokploy.commands.registry import app as registry_app
|
|
39
|
+
from kctl_dokploy.commands.report import app as report_app
|
|
40
|
+
from kctl_dokploy.commands.schedules import app as schedules_app
|
|
41
|
+
from kctl_dokploy.commands.security_cmd import app as security_app
|
|
42
|
+
from kctl_dokploy.commands.servers import app as servers_app
|
|
43
|
+
from kctl_dokploy.commands.settings import app as settings_app
|
|
44
|
+
from kctl_dokploy.commands.setup import app as setup_app
|
|
45
|
+
from kctl_dokploy.commands.status import app as status_app
|
|
46
|
+
from kctl_dokploy.commands.template import app as template_app
|
|
47
|
+
from kctl_dokploy.commands.users import app as users_app
|
|
48
|
+
from kctl_dokploy.commands.deploy import app as deploy_app
|
|
49
|
+
from kctl_dokploy.commands.patches import app as patches_app
|
|
50
|
+
from kctl_dokploy.commands.volume_backups import app as volume_backups_app
|
|
51
|
+
from kctl_dokploy.core.callbacks import AppContext
|
|
52
|
+
from kctl_dokploy.core.plugins import discover_and_register_plugins
|
|
53
|
+
from kctl_dokploy.commands.doctor_cmd import app as doctor_app
|
|
54
|
+
from kctl_dokploy.commands.skill_cmd import app as skill_app
|
|
55
|
+
from kctl_lib.self_update import notify_if_outdated
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def version_callback(value: bool) -> None:
|
|
59
|
+
if value:
|
|
60
|
+
typer.echo(f"kctl-dokploy {__version__}")
|
|
61
|
+
raise typer.Exit()
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
app = typer.Typer(
|
|
65
|
+
name="kctl-dokploy",
|
|
66
|
+
help="Kodemeio Dokploy CLI - manage your Dokploy deployment platform.",
|
|
67
|
+
no_args_is_help=True,
|
|
68
|
+
rich_markup_mode="rich",
|
|
69
|
+
pretty_exceptions_enable=False,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@app.callback()
|
|
74
|
+
def main(
|
|
75
|
+
ctx: typer.Context,
|
|
76
|
+
json_output: Annotated[bool, typer.Option("--json", help="Output as JSON (shortcut for --format json)")] = False,
|
|
77
|
+
quiet: Annotated[bool, typer.Option("--quiet", "-q", help="Suppress info messages")] = False,
|
|
78
|
+
output_format: Annotated[
|
|
79
|
+
str, typer.Option("--format", "-f", help="Output format: pretty, json, csv, yaml")
|
|
80
|
+
] = "pretty",
|
|
81
|
+
no_header: Annotated[bool, typer.Option("--no-header", help="Omit headers in CSV output")] = False,
|
|
82
|
+
debug: Annotated[bool, typer.Option("--debug", help="Enable debug logging")] = False,
|
|
83
|
+
profile: Annotated[str | None, typer.Option("--profile", "-p", help="Config profile name")] = None,
|
|
84
|
+
url: Annotated[str | None, typer.Option("--url", help="API URL override")] = None,
|
|
85
|
+
api_key: Annotated[str | None, typer.Option("--api-key", help="API key override")] = None,
|
|
86
|
+
version: Annotated[
|
|
87
|
+
bool, typer.Option("--version", "-V", callback=version_callback, is_eager=True, help="Show version")
|
|
88
|
+
] = False,
|
|
89
|
+
) -> None:
|
|
90
|
+
"""Kodemeio Dokploy CLI."""
|
|
91
|
+
import os
|
|
92
|
+
|
|
93
|
+
if debug:
|
|
94
|
+
os.environ["KCTL_DEBUG"] = "1"
|
|
95
|
+
|
|
96
|
+
effective_format = "json" if json_output else output_format
|
|
97
|
+
|
|
98
|
+
ctx.ensure_object(dict)
|
|
99
|
+
ctx.obj = AppContext(
|
|
100
|
+
json_mode=json_output or effective_format == "json",
|
|
101
|
+
quiet=quiet,
|
|
102
|
+
format=effective_format,
|
|
103
|
+
no_header=no_header,
|
|
104
|
+
debug=debug,
|
|
105
|
+
profile=profile,
|
|
106
|
+
url_override=url,
|
|
107
|
+
api_key_override=api_key,
|
|
108
|
+
)
|
|
109
|
+
notify_if_outdated(ctx.obj.output, "kctl-dokploy", __version__)
|
|
110
|
+
|
|
111
|
+
# Emit the profile banner once per invocation (no-op when profile is None,
|
|
112
|
+
# quiet, or json mode — emit_banner handles those guards internally).
|
|
113
|
+
if profile:
|
|
114
|
+
from kctl_lib.config import get_service_config, resolve_inheritance_chain
|
|
115
|
+
|
|
116
|
+
chain = resolve_inheritance_chain(profile)
|
|
117
|
+
summary: str | None = None
|
|
118
|
+
try:
|
|
119
|
+
dokploy_cfg = get_service_config(profile, "dokploy")
|
|
120
|
+
summary = dokploy_cfg.get("url") if dokploy_cfg else None
|
|
121
|
+
except Exception:
|
|
122
|
+
summary = None
|
|
123
|
+
ctx.obj.emit_banner(
|
|
124
|
+
app="kctl-dokploy",
|
|
125
|
+
inheritance_chain=chain,
|
|
126
|
+
service_summary=summary,
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
# ---------------------------------------------------------------------------
|
|
131
|
+
# Top-level command groups (platform-wide resources)
|
|
132
|
+
# ---------------------------------------------------------------------------
|
|
133
|
+
app.add_typer(config_app, name="config")
|
|
134
|
+
app.add_typer(projects_app, name="projects")
|
|
135
|
+
app.add_typer(applications_app, name="applications")
|
|
136
|
+
app.add_typer(compose_app, name="compose")
|
|
137
|
+
app.add_typer(servers_app, name="servers")
|
|
138
|
+
app.add_typer(databases_app, name="databases")
|
|
139
|
+
app.add_typer(registry_app, name="registry")
|
|
140
|
+
app.add_typer(users_app, name="users")
|
|
141
|
+
app.add_typer(git_app, name="git")
|
|
142
|
+
app.add_typer(notifications_app, name="notifications")
|
|
143
|
+
app.add_typer(certificates_app, name="certificates")
|
|
144
|
+
app.add_typer(settings_app, name="settings")
|
|
145
|
+
app.add_typer(docker_app, name="docker")
|
|
146
|
+
app.add_typer(dashboard_app, name="dashboard")
|
|
147
|
+
app.add_typer(diagnose_app, name="diagnose")
|
|
148
|
+
app.add_typer(deploy_app, name="deploy")
|
|
149
|
+
app.add_typer(report_app, name="report")
|
|
150
|
+
app.add_typer(template_app, name="template")
|
|
151
|
+
app.add_typer(audit_app, name="audit")
|
|
152
|
+
app.add_typer(setup_app, name="setup")
|
|
153
|
+
|
|
154
|
+
# ---------------------------------------------------------------------------
|
|
155
|
+
# Compose sub-commands (mirrors Dokploy UI tabs)
|
|
156
|
+
# ---------------------------------------------------------------------------
|
|
157
|
+
compose_app.add_typer(backups_app, name="backups")
|
|
158
|
+
compose_app.add_typer(domains_app, name="domains")
|
|
159
|
+
compose_app.add_typer(env_app, name="env")
|
|
160
|
+
compose_app.add_typer(deployments_app, name="deployments")
|
|
161
|
+
compose_app.add_typer(schedules_app, name="schedules")
|
|
162
|
+
compose_app.add_typer(patches_app, name="patches")
|
|
163
|
+
compose_app.add_typer(volume_backups_app, name="volume-backups")
|
|
164
|
+
compose_app.add_typer(mounts_app, name="mounts")
|
|
165
|
+
compose_app.add_typer(ports_app, name="ports")
|
|
166
|
+
compose_app.add_typer(security_app, name="security")
|
|
167
|
+
compose_app.add_typer(redirects_app, name="redirects")
|
|
168
|
+
compose_app.add_typer(bulk_app, name="bulk")
|
|
169
|
+
compose_app.add_typer(autodeploy_app, name="autodeploy")
|
|
170
|
+
|
|
171
|
+
# ---------------------------------------------------------------------------
|
|
172
|
+
# Server sub-commands
|
|
173
|
+
# ---------------------------------------------------------------------------
|
|
174
|
+
servers_app.add_typer(monitoring_app, name="monitoring")
|
|
175
|
+
servers_app.add_typer(cluster_app, name="cluster")
|
|
176
|
+
|
|
177
|
+
# ---------------------------------------------------------------------------
|
|
178
|
+
# Project sub-commands
|
|
179
|
+
# ---------------------------------------------------------------------------
|
|
180
|
+
projects_app.add_typer(environments_app, name="environments")
|
|
181
|
+
|
|
182
|
+
# ---------------------------------------------------------------------------
|
|
183
|
+
# Merged groups
|
|
184
|
+
# ---------------------------------------------------------------------------
|
|
185
|
+
# status → absorbed into dashboard (status.health = dashboard.show)
|
|
186
|
+
# pipeline → removed (duplicates compose redeploy + deploy apply)
|
|
187
|
+
# maintenance → absorbed into diagnose
|
|
188
|
+
|
|
189
|
+
# Merge maintenance commands into diagnose
|
|
190
|
+
diagnose_app.add_typer(maintenance_app, name="maintenance")
|
|
191
|
+
|
|
192
|
+
# ---------------------------------------------------------------------------
|
|
193
|
+
# Backward compatibility — hidden aliases (old top-level still works)
|
|
194
|
+
# ---------------------------------------------------------------------------
|
|
195
|
+
app.add_typer(backups_app, name="backups", hidden=True)
|
|
196
|
+
app.add_typer(domains_app, name="domains", hidden=True)
|
|
197
|
+
app.add_typer(env_app, name="env", hidden=True)
|
|
198
|
+
app.add_typer(deployments_app, name="deployments", hidden=True)
|
|
199
|
+
app.add_typer(schedules_app, name="schedules", hidden=True)
|
|
200
|
+
app.add_typer(patches_app, name="patches", hidden=True)
|
|
201
|
+
app.add_typer(volume_backups_app, name="volume-backups", hidden=True)
|
|
202
|
+
app.add_typer(mounts_app, name="mounts", hidden=True)
|
|
203
|
+
app.add_typer(ports_app, name="ports", hidden=True)
|
|
204
|
+
app.add_typer(security_app, name="security", hidden=True)
|
|
205
|
+
app.add_typer(redirects_app, name="redirects", hidden=True)
|
|
206
|
+
app.add_typer(bulk_app, name="bulk", hidden=True)
|
|
207
|
+
app.add_typer(monitoring_app, name="monitoring", hidden=True)
|
|
208
|
+
app.add_typer(environments_app, name="environments", hidden=True)
|
|
209
|
+
app.add_typer(cluster_app, name="cluster", hidden=True)
|
|
210
|
+
app.add_typer(pipeline_app, name="pipeline", hidden=True)
|
|
211
|
+
app.add_typer(status_app, name="status", hidden=True)
|
|
212
|
+
app.add_typer(maintenance_app, name="maintenance", hidden=True)
|
|
213
|
+
app.add_typer(doctor_app, name="doctor")
|
|
214
|
+
app.add_typer(skill_app, name="skill", hidden=True)
|
|
215
|
+
|
|
216
|
+
# Hidden aliases for power users
|
|
217
|
+
register_aliases(app)
|
|
218
|
+
|
|
219
|
+
# Discover and register plugins
|
|
220
|
+
discover_and_register_plugins(app)
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
@app.command("self-update")
|
|
224
|
+
def self_update_cmd(ctx: typer.Context) -> None:
|
|
225
|
+
"""Check for updates and upgrade kctl-dokploy."""
|
|
226
|
+
actx = ctx.obj
|
|
227
|
+
out = actx.output
|
|
228
|
+
|
|
229
|
+
from kctl_lib.self_update import check_update
|
|
230
|
+
from kctl_lib.self_update import update as do_update
|
|
231
|
+
|
|
232
|
+
latest = check_update("kctl-dokploy", __version__)
|
|
233
|
+
if latest:
|
|
234
|
+
out.info(f"Updating to {latest}...")
|
|
235
|
+
do_update("kctl-dokploy")
|
|
236
|
+
out.success(f"Updated to {latest}")
|
|
237
|
+
else:
|
|
238
|
+
out.success("Already up to date")
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
@app.command()
|
|
242
|
+
def completions(
|
|
243
|
+
shell: Annotated[str, typer.Argument(help="Shell type: zsh, bash, fish")] = "zsh",
|
|
244
|
+
install: Annotated[bool, typer.Option("--install", help="Install completions")] = False,
|
|
245
|
+
) -> None:
|
|
246
|
+
"""Generate or install shell completions."""
|
|
247
|
+
from kctl_lib.completions import get_completion_script, install_completions
|
|
248
|
+
|
|
249
|
+
if install:
|
|
250
|
+
path = install_completions("kctl-dokploy", shell)
|
|
251
|
+
if path:
|
|
252
|
+
typer.echo(f"Completions installed to {path}")
|
|
253
|
+
else:
|
|
254
|
+
typer.echo(f"Could not install completions for {shell}", err=True)
|
|
255
|
+
raise typer.Exit(code=1)
|
|
256
|
+
else:
|
|
257
|
+
script = get_completion_script("kctl-dokploy", shell)
|
|
258
|
+
typer.echo(script)
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def _run() -> None:
|
|
262
|
+
"""Entry point with error handling."""
|
|
263
|
+
try:
|
|
264
|
+
app()
|
|
265
|
+
except KctlError as e:
|
|
266
|
+
handle_cli_error(e)
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
if __name__ == "__main__":
|
|
270
|
+
_run()
|
|
File without changes
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""Hidden command aliases for power users.
|
|
2
|
+
|
|
3
|
+
Short aliases that re-invoke the full command with context propagation.
|
|
4
|
+
Hidden from --help to keep it clean, but discoverable by power users.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import subprocess
|
|
10
|
+
import sys
|
|
11
|
+
|
|
12
|
+
import typer
|
|
13
|
+
|
|
14
|
+
from kctl_dokploy.core.callbacks import AppContext
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _base_cmd(ctx: typer.Context) -> list[str]:
|
|
18
|
+
"""Build base command with inherited global options."""
|
|
19
|
+
cmd = ["kctl-dokploy"]
|
|
20
|
+
actx: AppContext = ctx.obj
|
|
21
|
+
if actx.profile:
|
|
22
|
+
cmd.extend(["-p", actx.profile])
|
|
23
|
+
if actx.json_mode:
|
|
24
|
+
cmd.append("--json")
|
|
25
|
+
elif actx.format != "pretty":
|
|
26
|
+
cmd.extend(["--format", actx.format])
|
|
27
|
+
if actx.quiet:
|
|
28
|
+
cmd.append("--quiet")
|
|
29
|
+
if actx.debug:
|
|
30
|
+
cmd.append("--debug")
|
|
31
|
+
return cmd
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def register_aliases(app: typer.Typer) -> None:
|
|
35
|
+
"""Register all hidden alias commands on the main app."""
|
|
36
|
+
|
|
37
|
+
@app.command("cl", hidden=True, help="Alias: compose list")
|
|
38
|
+
def cl(ctx: typer.Context) -> None:
|
|
39
|
+
sys.exit(subprocess.call([*_base_cmd(ctx), "compose", "list"]))
|
|
40
|
+
|
|
41
|
+
@app.command("cs", hidden=True, help="Alias: compose start <id>")
|
|
42
|
+
def cs(ctx: typer.Context, compose_id: str = typer.Argument(help="Compose ID")) -> None:
|
|
43
|
+
sys.exit(subprocess.call([*_base_cmd(ctx), "compose", "start", compose_id]))
|
|
44
|
+
|
|
45
|
+
@app.command("cr", hidden=True, help="Alias: compose redeploy <id>")
|
|
46
|
+
def cr(ctx: typer.Context, compose_id: str = typer.Argument(help="Compose ID")) -> None:
|
|
47
|
+
sys.exit(subprocess.call([*_base_cmd(ctx), "compose", "redeploy", compose_id]))
|
|
48
|
+
|
|
49
|
+
@app.command("sl", hidden=True, help="Alias: servers list")
|
|
50
|
+
def sl(ctx: typer.Context) -> None:
|
|
51
|
+
sys.exit(subprocess.call([*_base_cmd(ctx), "servers", "list"]))
|
|
52
|
+
|
|
53
|
+
@app.command("pl", hidden=True, help="Alias: projects list")
|
|
54
|
+
def pl(ctx: typer.Context) -> None:
|
|
55
|
+
sys.exit(subprocess.call([*_base_cmd(ctx), "projects", "list"]))
|
|
56
|
+
|
|
57
|
+
@app.command("ds", hidden=True, help="Alias: dashboard show")
|
|
58
|
+
def ds(ctx: typer.Context) -> None:
|
|
59
|
+
sys.exit(subprocess.call([*_base_cmd(ctx), "dashboard", "show"]))
|
|
60
|
+
|
|
61
|
+
@app.command("dg", hidden=True, help="Alias: diagnose run")
|
|
62
|
+
def dg(ctx: typer.Context) -> None:
|
|
63
|
+
sys.exit(subprocess.call([*_base_cmd(ctx), "diagnose", "run"]))
|
|
64
|
+
|
|
65
|
+
@app.command("pp", hidden=True, help="Alias: pipeline deploy")
|
|
66
|
+
def pp(
|
|
67
|
+
ctx: typer.Context,
|
|
68
|
+
name: str = typer.Option(..., "--name", "-n"),
|
|
69
|
+
project: str = typer.Option(..., "--project", "-p"),
|
|
70
|
+
file: str = typer.Option(..., "--file", "-f"),
|
|
71
|
+
) -> None:
|
|
72
|
+
sys.exit(
|
|
73
|
+
subprocess.call(
|
|
74
|
+
[
|
|
75
|
+
*_base_cmd(ctx),
|
|
76
|
+
"pipeline",
|
|
77
|
+
"deploy",
|
|
78
|
+
"--name",
|
|
79
|
+
name,
|
|
80
|
+
"--project",
|
|
81
|
+
project,
|
|
82
|
+
"--file",
|
|
83
|
+
file,
|
|
84
|
+
]
|
|
85
|
+
)
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
@app.command("dl", hidden=True, help="Alias: deployments list")
|
|
89
|
+
def dl(ctx: typer.Context) -> None:
|
|
90
|
+
sys.exit(subprocess.call([*_base_cmd(ctx), "deployments", "list"]))
|
|
91
|
+
|
|
92
|
+
@app.command("bl", hidden=True, help="Alias: backups list")
|
|
93
|
+
def bl(ctx: typer.Context) -> None:
|
|
94
|
+
sys.exit(subprocess.call([*_base_cmd(ctx), "backups", "list"]))
|