mantis-cli 21.0.0__tar.gz → 22.0.1__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 (48) hide show
  1. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/PKG-INFO +118 -51
  2. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/README.md +117 -50
  3. mantis_cli-22.0.1/mantis/__init__.py +1 -0
  4. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis/app.py +30 -5
  5. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis/command_line.py +11 -2
  6. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis/commands/__init__.py +6 -4
  7. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis/commands/compose.py +2 -1
  8. mantis_cli-22.0.1/mantis/commands/configuration.py +16 -0
  9. mantis_cli-21.0.0/mantis/commands/config.py → mantis_cli-22.0.1/mantis/commands/connection.py +1 -7
  10. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis/commands/django.py +9 -1
  11. mantis_cli-22.0.1/mantis/commands/secrets.py +77 -0
  12. mantis_cli-22.0.1/mantis/config.py +323 -0
  13. mantis_cli-22.0.1/mantis/extensions/django.py +85 -0
  14. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis/extensions/postgres.py +3 -3
  15. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis/managers.py +116 -46
  16. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis_cli.egg-info/PKG-INFO +118 -51
  17. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis_cli.egg-info/SOURCES.txt +7 -4
  18. mantis_cli-22.0.1/tests/test_config.py +388 -0
  19. mantis_cli-22.0.1/tests/test_managers.py +316 -0
  20. mantis_cli-21.0.0/mantis/__init__.py +0 -1
  21. mantis_cli-21.0.0/mantis/commands/crypto.py +0 -38
  22. mantis_cli-21.0.0/mantis/config.py +0 -192
  23. mantis_cli-21.0.0/mantis/extensions/django.py +0 -35
  24. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/LICENSE +0 -0
  25. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/MANIFEST.in +0 -0
  26. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis/__main__.py +0 -0
  27. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis/commands/containers.py +0 -0
  28. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis/commands/core.py +0 -0
  29. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis/commands/images.py +0 -0
  30. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis/commands/nginx.py +0 -0
  31. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis/commands/postgres.py +0 -0
  32. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis/commands/services.py +0 -0
  33. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis/commands/volumes.py +0 -0
  34. /mantis_cli-21.0.0/mantis/crypto.py → /mantis_cli-22.0.1/mantis/cryptography.py +0 -0
  35. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis/environment.py +0 -0
  36. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis/extensions/__init__.py +0 -0
  37. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis/extensions/nginx.py +0 -0
  38. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis/helpers.py +0 -0
  39. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis/mantis.tpl +0 -0
  40. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis/schema.py +0 -0
  41. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis_cli.egg-info/dependency_links.txt +0 -0
  42. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis_cli.egg-info/entry_points.txt +0 -0
  43. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis_cli.egg-info/requires.txt +0 -0
  44. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/mantis_cli.egg-info/top_level.txt +0 -0
  45. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/setup.cfg +0 -0
  46. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/setup.py +0 -0
  47. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/tests/__init__.py +0 -0
  48. {mantis_cli-21.0.0 → mantis_cli-22.0.1}/tests/test_command_line.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mantis_cli
3
- Version: 21.0.0
3
+ Version: 22.0.1
4
4
  Summary: Management command to build and deploy webapps, especially based on Django
5
5
  Home-page: https://github.com/PragmaticMates/mantis-cli
6
6
  Author: Erik Telepovský
@@ -199,65 +199,131 @@ The environment is also used as an identifier for remote connection.
199
199
 
200
200
  ### Commands
201
201
 
202
- Run `mantis commands` to see all available commands with their descriptions.
203
-
204
- | Command / Shortcut | Description |
205
- |-------------------------------|-------------------------------------------------------------------|
206
- | status / s | Prints images and containers |
207
- | deploy [--dirty] / d | Runs deployment process |
208
- | build [services...] / b | Builds all services with Dockerfiles |
209
- | pull [services...] / p | Pulls required images for services |
210
- | push [services...] / u | Push built images to repository |
211
- | upload | Uploads config, compose and env files to server |
212
- | clean / c | Clean images, containers, networks |
213
- | logs [container] / l | Prints logs of containers |
214
- | networks / n | Prints docker networks |
215
- | healthcheck [container] / hc | Execute health-check of container |
216
- | up [params...] | Calls compose up |
217
- | down [params...] | Calls compose down |
218
- | restart [service] | Restarts all containers |
219
- | stop [containers...] | Stops containers |
220
- | start [containers...] | Starts containers |
221
- | kill [containers...] | Kills containers |
222
- | remove [containers...] | Removes containers |
223
- | bash <container> | Runs bash in container |
224
- | sh <container> | Runs sh in container |
225
- | exec <container> <command> | Executes command in container |
226
- | ssh | Connects to remote host via SSH |
227
- | scale <service> <num> | Scales service to given number |
228
- | zero-downtime [service] | Runs zero-downtime deployment |
229
- | encrypt-env [--force] | Encrypts environment files |
230
- | decrypt-env [--force] | Decrypts environment files |
231
- | check-env | Compares encrypted and decrypted env files |
232
- | generate-key | Creates new encryption key |
233
- | read-key | Returns encryption key value |
234
- | check-config | Validates config file |
235
- | contexts | Prints all docker contexts |
236
- | create-context | Creates docker context |
237
- | services | Lists all defined services |
238
- | commands | Lists all available commands |
202
+ Run `mantis --help` to see all available commands with their descriptions.
203
+
204
+ **Core commands:**
205
+
206
+ | Command / Shortcut | Description |
207
+ |---------------------------------------|-----------------------------------------------------------|
208
+ | status / s | Prints images and containers |
209
+ | deploy [--dirty] [--strategy] / d | Runs deployment process |
210
+ | rolling-update [service] / ru | Performs rolling update of containers one-by-one |
211
+ | clean [params...] / c | Clean images, containers, networks |
212
+
213
+ **Files:**
214
+
215
+ | Command / Shortcut | Description |
216
+ |---------------------------------------|-----------------------------------------------------------|
217
+ | upload / u | Uploads config, compose and env files to server |
218
+
219
+ **Images:**
220
+
221
+ | Command / Shortcut | Description |
222
+ |---------------------------------------|-----------------------------------------------------------|
223
+ | build [SERVICES...] / b | Builds all services with Dockerfiles |
224
+ | pull [SERVICES...] / pl | Pulls required images for services |
225
+ | push [SERVICES...] / p | Push built images to repository |
226
+ | get-image-name SERVICE | Gets image name for service |
227
+
228
+ **Containers:**
229
+
230
+ | Command / Shortcut | Description |
231
+ |---------------------------------------|-----------------------------------------------------------|
232
+ | logs [CONTAINER] / l | Prints logs of containers |
233
+ | networks / n | Prints docker networks |
234
+ | healthcheck [CONTAINER] / hc | Execute health-check of container |
235
+ | stop [CONTAINERS...] | Stops containers |
236
+ | start [CONTAINERS...] | Starts containers |
237
+ | kill [CONTAINERS...] | Kills containers |
238
+ | remove [CONTAINERS...] [--force] | Removes containers |
239
+ | rename CONTAINER NEW_NAME | Rename container |
240
+ | bash CONTAINER | Runs bash in container |
241
+ | sh CONTAINER | Runs sh in container |
242
+ | exec CONTAINER COMMAND... | Executes command in container |
243
+ | exec-it CONTAINER COMMAND... | Executes command in container (interactive) |
244
+ | get-container-name SERVICE | Gets container name for service |
245
+ | remove-suffixes [PREFIX] | Removes numerical suffixes from container names |
246
+
247
+ **Compose:**
248
+
249
+ | Command | Description |
250
+ |---------------------------------------|-----------------------------------------------------------|
251
+ | up [PARAMS...] | Calls compose up |
252
+ | down [PARAMS...] | Calls compose down |
253
+ | run PARAMS... | Calls compose run with params |
254
+
255
+ **Services:**
256
+
257
+ | Command | Description |
258
+ |---------------------------------------|-----------------------------------------------------------|
259
+ | restart [SERVICE] | Restarts containers |
260
+ | scale SERVICE NUM | Scales service to given number |
261
+ | zero-downtime [SERVICE] | Runs zero-downtime deployment |
262
+ | restart-service SERVICE | Restarts a specific service |
263
+ | services | Lists all defined services |
264
+ | services-to-build | Lists services that will be built |
265
+
266
+ **Volumes:**
267
+
268
+ | Command | Description |
269
+ |---------------------------------------|-----------------------------------------------------------|
270
+ | backup-volume VOLUME | Backups volume to a file |
271
+ | restore-volume VOLUME FILE | Restores volume from a file |
272
+
273
+ **Secrets:**
274
+
275
+ | Command | Description |
276
+ |---------------------------------------|-----------------------------------------------------------|
277
+ | show-env [KEYWORD] | Shows environment variables from .env files |
278
+ | encrypt-env [--force] | Encrypts environment files |
279
+ | decrypt-env [--force] | Decrypts environment files |
280
+ | check-env | Compares encrypted and decrypted env files |
281
+ | generate-key | Creates new encryption key |
282
+ | read-key | Returns encryption key value |
283
+
284
+ **Configuration:**
285
+
286
+ | Command | Description |
287
+ |---------------------------------------|-----------------------------------------------------------|
288
+ | show-config | Shows the JSON mantis config |
289
+ | check-config | Validates config file |
290
+
291
+ **Connections:**
292
+
293
+ | Command | Description |
294
+ |---------------------------------------|-----------------------------------------------------------|
295
+ | contexts | Prints all docker contexts |
296
+ | create-context | Creates docker context |
297
+ | ssh | Connects to remote host via SSH |
239
298
 
240
299
  **Django extension:**
241
300
 
242
- | Command | Description |
243
- |-------------------------------|-------------------------------------------------------------------|
244
- | shell | Runs Django shell |
245
- | manage <command> [args...] | Runs Django manage command |
246
- | send-test-email | Sends test email to admins |
301
+ | Command | Description |
302
+ |---------------------------------------|-----------------------------------------------------------|
303
+ | shell | Runs Django shell |
304
+ | manage [OPTIONS] CMD [ARGS...] | Runs Django manage command |
305
+ | send-test-email | Sends test email to admins |
306
+ | reset-migrations | Clears migration history and fakes all migrations |
307
+
308
+ The `manage` command supports health-check options:
309
+ - `--if-healthy`: Only execute if the container is currently healthy. Skips with a warning if not healthy.
310
+ - `--healthy-timeout N`: Wait up to N seconds for the container to become healthy before executing. Polls every second and skips the command if the timeout is reached.
247
311
 
248
312
  **PostgreSQL extension:**
249
313
 
250
- | Command | Description |
251
- |-------------------------------|-------------------------------------------------------------------|
252
- | psql | Starts psql console |
253
- | pg-dump [--data-only] [--table TABLE] | Backups database |
254
- | pg-restore <filename> [--table TABLE] | Restores database from backup |
314
+ | Command | Description |
315
+ |---------------------------------------|-----------------------------------------------------------|
316
+ | psql | Starts psql console |
317
+ | pg-dump [--data-only] [--table] | Backups PostgreSQL database |
318
+ | pg-dump-data [--table] | Backups PostgreSQL database (data only) |
319
+ | pg-restore FILENAME [--table] | Restores database from backup |
320
+ | pg-restore-data FILENAME TABLE | Restores database data from backup |
255
321
 
256
322
  **Nginx extension:**
257
323
 
258
- | Command | Description |
259
- |-------------------------------|-------------------------------------------------------------------|
260
- | reload-webserver | Reloads nginx |
324
+ | Command | Description |
325
+ |---------------------------------------|-----------------------------------------------------------|
326
+ | reload-webserver | Reloads nginx webserver |
261
327
 
262
328
  ### Examples
263
329
 
@@ -274,6 +340,7 @@ mantis -e stage build web api + push + deploy + status
274
340
  # Commands with arguments
275
341
  mantis -e production deploy --dirty
276
342
  mantis -e production manage migrate
343
+ mantis -e production manage --healthy-timeout 60 migrate
277
344
  mantis -e production pg-dump --data-only --table users
278
345
 
279
346
  # Single connection mode (no environment needed)
@@ -177,65 +177,131 @@ The environment is also used as an identifier for remote connection.
177
177
 
178
178
  ### Commands
179
179
 
180
- Run `mantis commands` to see all available commands with their descriptions.
181
-
182
- | Command / Shortcut | Description |
183
- |-------------------------------|-------------------------------------------------------------------|
184
- | status / s | Prints images and containers |
185
- | deploy [--dirty] / d | Runs deployment process |
186
- | build [services...] / b | Builds all services with Dockerfiles |
187
- | pull [services...] / p | Pulls required images for services |
188
- | push [services...] / u | Push built images to repository |
189
- | upload | Uploads config, compose and env files to server |
190
- | clean / c | Clean images, containers, networks |
191
- | logs [container] / l | Prints logs of containers |
192
- | networks / n | Prints docker networks |
193
- | healthcheck [container] / hc | Execute health-check of container |
194
- | up [params...] | Calls compose up |
195
- | down [params...] | Calls compose down |
196
- | restart [service] | Restarts all containers |
197
- | stop [containers...] | Stops containers |
198
- | start [containers...] | Starts containers |
199
- | kill [containers...] | Kills containers |
200
- | remove [containers...] | Removes containers |
201
- | bash <container> | Runs bash in container |
202
- | sh <container> | Runs sh in container |
203
- | exec <container> <command> | Executes command in container |
204
- | ssh | Connects to remote host via SSH |
205
- | scale <service> <num> | Scales service to given number |
206
- | zero-downtime [service] | Runs zero-downtime deployment |
207
- | encrypt-env [--force] | Encrypts environment files |
208
- | decrypt-env [--force] | Decrypts environment files |
209
- | check-env | Compares encrypted and decrypted env files |
210
- | generate-key | Creates new encryption key |
211
- | read-key | Returns encryption key value |
212
- | check-config | Validates config file |
213
- | contexts | Prints all docker contexts |
214
- | create-context | Creates docker context |
215
- | services | Lists all defined services |
216
- | commands | Lists all available commands |
180
+ Run `mantis --help` to see all available commands with their descriptions.
181
+
182
+ **Core commands:**
183
+
184
+ | Command / Shortcut | Description |
185
+ |---------------------------------------|-----------------------------------------------------------|
186
+ | status / s | Prints images and containers |
187
+ | deploy [--dirty] [--strategy] / d | Runs deployment process |
188
+ | rolling-update [service] / ru | Performs rolling update of containers one-by-one |
189
+ | clean [params...] / c | Clean images, containers, networks |
190
+
191
+ **Files:**
192
+
193
+ | Command / Shortcut | Description |
194
+ |---------------------------------------|-----------------------------------------------------------|
195
+ | upload / u | Uploads config, compose and env files to server |
196
+
197
+ **Images:**
198
+
199
+ | Command / Shortcut | Description |
200
+ |---------------------------------------|-----------------------------------------------------------|
201
+ | build [SERVICES...] / b | Builds all services with Dockerfiles |
202
+ | pull [SERVICES...] / pl | Pulls required images for services |
203
+ | push [SERVICES...] / p | Push built images to repository |
204
+ | get-image-name SERVICE | Gets image name for service |
205
+
206
+ **Containers:**
207
+
208
+ | Command / Shortcut | Description |
209
+ |---------------------------------------|-----------------------------------------------------------|
210
+ | logs [CONTAINER] / l | Prints logs of containers |
211
+ | networks / n | Prints docker networks |
212
+ | healthcheck [CONTAINER] / hc | Execute health-check of container |
213
+ | stop [CONTAINERS...] | Stops containers |
214
+ | start [CONTAINERS...] | Starts containers |
215
+ | kill [CONTAINERS...] | Kills containers |
216
+ | remove [CONTAINERS...] [--force] | Removes containers |
217
+ | rename CONTAINER NEW_NAME | Rename container |
218
+ | bash CONTAINER | Runs bash in container |
219
+ | sh CONTAINER | Runs sh in container |
220
+ | exec CONTAINER COMMAND... | Executes command in container |
221
+ | exec-it CONTAINER COMMAND... | Executes command in container (interactive) |
222
+ | get-container-name SERVICE | Gets container name for service |
223
+ | remove-suffixes [PREFIX] | Removes numerical suffixes from container names |
224
+
225
+ **Compose:**
226
+
227
+ | Command | Description |
228
+ |---------------------------------------|-----------------------------------------------------------|
229
+ | up [PARAMS...] | Calls compose up |
230
+ | down [PARAMS...] | Calls compose down |
231
+ | run PARAMS... | Calls compose run with params |
232
+
233
+ **Services:**
234
+
235
+ | Command | Description |
236
+ |---------------------------------------|-----------------------------------------------------------|
237
+ | restart [SERVICE] | Restarts containers |
238
+ | scale SERVICE NUM | Scales service to given number |
239
+ | zero-downtime [SERVICE] | Runs zero-downtime deployment |
240
+ | restart-service SERVICE | Restarts a specific service |
241
+ | services | Lists all defined services |
242
+ | services-to-build | Lists services that will be built |
243
+
244
+ **Volumes:**
245
+
246
+ | Command | Description |
247
+ |---------------------------------------|-----------------------------------------------------------|
248
+ | backup-volume VOLUME | Backups volume to a file |
249
+ | restore-volume VOLUME FILE | Restores volume from a file |
250
+
251
+ **Secrets:**
252
+
253
+ | Command | Description |
254
+ |---------------------------------------|-----------------------------------------------------------|
255
+ | show-env [KEYWORD] | Shows environment variables from .env files |
256
+ | encrypt-env [--force] | Encrypts environment files |
257
+ | decrypt-env [--force] | Decrypts environment files |
258
+ | check-env | Compares encrypted and decrypted env files |
259
+ | generate-key | Creates new encryption key |
260
+ | read-key | Returns encryption key value |
261
+
262
+ **Configuration:**
263
+
264
+ | Command | Description |
265
+ |---------------------------------------|-----------------------------------------------------------|
266
+ | show-config | Shows the JSON mantis config |
267
+ | check-config | Validates config file |
268
+
269
+ **Connections:**
270
+
271
+ | Command | Description |
272
+ |---------------------------------------|-----------------------------------------------------------|
273
+ | contexts | Prints all docker contexts |
274
+ | create-context | Creates docker context |
275
+ | ssh | Connects to remote host via SSH |
217
276
 
218
277
  **Django extension:**
219
278
 
220
- | Command | Description |
221
- |-------------------------------|-------------------------------------------------------------------|
222
- | shell | Runs Django shell |
223
- | manage <command> [args...] | Runs Django manage command |
224
- | send-test-email | Sends test email to admins |
279
+ | Command | Description |
280
+ |---------------------------------------|-----------------------------------------------------------|
281
+ | shell | Runs Django shell |
282
+ | manage [OPTIONS] CMD [ARGS...] | Runs Django manage command |
283
+ | send-test-email | Sends test email to admins |
284
+ | reset-migrations | Clears migration history and fakes all migrations |
285
+
286
+ The `manage` command supports health-check options:
287
+ - `--if-healthy`: Only execute if the container is currently healthy. Skips with a warning if not healthy.
288
+ - `--healthy-timeout N`: Wait up to N seconds for the container to become healthy before executing. Polls every second and skips the command if the timeout is reached.
225
289
 
226
290
  **PostgreSQL extension:**
227
291
 
228
- | Command | Description |
229
- |-------------------------------|-------------------------------------------------------------------|
230
- | psql | Starts psql console |
231
- | pg-dump [--data-only] [--table TABLE] | Backups database |
232
- | pg-restore <filename> [--table TABLE] | Restores database from backup |
292
+ | Command | Description |
293
+ |---------------------------------------|-----------------------------------------------------------|
294
+ | psql | Starts psql console |
295
+ | pg-dump [--data-only] [--table] | Backups PostgreSQL database |
296
+ | pg-dump-data [--table] | Backups PostgreSQL database (data only) |
297
+ | pg-restore FILENAME [--table] | Restores database from backup |
298
+ | pg-restore-data FILENAME TABLE | Restores database data from backup |
233
299
 
234
300
  **Nginx extension:**
235
301
 
236
- | Command | Description |
237
- |-------------------------------|-------------------------------------------------------------------|
238
- | reload-webserver | Reloads nginx |
302
+ | Command | Description |
303
+ |---------------------------------------|-----------------------------------------------------------|
304
+ | reload-webserver | Reloads nginx webserver |
239
305
 
240
306
  ### Examples
241
307
 
@@ -252,6 +318,7 @@ mantis -e stage build web api + push + deploy + status
252
318
  # Commands with arguments
253
319
  mantis -e production deploy --dirty
254
320
  mantis -e production manage migrate
321
+ mantis -e production manage --healthy-timeout 60 migrate
255
322
  mantis -e production pg-dump --data-only --table users
256
323
 
257
324
  # Single connection mode (no environment needed)
@@ -0,0 +1 @@
1
+ VERSION = '22.0.1'
@@ -18,7 +18,9 @@ EPILOG = """\
18
18
 
19
19
  mantis -e production deploy --dirty
20
20
 
21
- mantis -e production build + push + deploy
21
+ mantis -e production build [yellow]+[/yellow] push [yellow]+[/yellow] deploy
22
+
23
+ mantis -e production build web api [yellow]+[/yellow] push [yellow]+[/yellow] deploy
22
24
 
23
25
  mantis -e prod manage migrate --fake
24
26
 
@@ -49,6 +51,9 @@ app = typer.Typer(
49
51
  # Commands that don't require environment (populated by @no_env_required decorator)
50
52
  NO_ENV_COMMANDS: set[str] = set()
51
53
 
54
+ # Deferred shortcuts (registered after all commands to appear at end of help)
55
+ _DEFERRED_SHORTCUTS: list[tuple] = []
56
+
52
57
  # Cache hostname
53
58
  _hostname = socket.gethostname()
54
59
 
@@ -159,22 +164,28 @@ def command(
159
164
  kwargs['rich_help_panel'] = panel
160
165
  registered = app.command(cmd_name, **kwargs)(wrapper)
161
166
 
162
- # Register shortcut
167
+ # Defer shortcut registration (to appear at end of help)
163
168
  if shortcut:
164
- app.command(shortcut, rich_help_panel="Shortcuts", help=f"Alias for '{cmd_name}'")(wrapper)
169
+ _DEFERRED_SHORTCUTS.append((shortcut, cmd_name, wrapper))
165
170
 
166
171
  return registered
167
172
 
168
173
  return decorator
169
174
 
170
175
 
176
+ def register_shortcuts():
177
+ """Register all deferred shortcuts. Call after all commands are imported."""
178
+ for shortcut, cmd_name, wrapper in _DEFERRED_SHORTCUTS:
179
+ app.command(shortcut, rich_help_panel="Shortcuts", help=f"Alias for '{cmd_name}'")(wrapper)
180
+
181
+
171
182
  def version_callback(value: bool):
172
183
  if value:
173
184
  typer.echo(f"Mantis v{VERSION}")
174
185
  raise typer.Exit()
175
186
 
176
187
 
177
- @app.callback()
188
+ @app.callback(invoke_without_command=True)
178
189
  def main(
179
190
  ctx: typer.Context,
180
191
  environment: Optional[str] = typer.Option(None, "--env", "-e", help="Environment ID"),
@@ -189,6 +200,20 @@ def main(
189
200
  if ctx.resilient_parsing or '--help' in sys.argv or '-h' in sys.argv:
190
201
  return
191
202
 
203
+ # Get all commands being invoked (find non-option arguments after global options)
204
+ commands = []
205
+ skip_next = False
206
+ for arg in sys.argv[1:]:
207
+ if skip_next:
208
+ skip_next = False
209
+ continue
210
+ if arg in ('-e', '--env', '-m', '--mode'):
211
+ skip_next = True
212
+ continue
213
+ if arg.startswith('-') or arg == '+':
214
+ continue
215
+ commands.append(arg)
216
+
192
217
  state._mode = mode
193
218
  state._dry_run = dry_run
194
- state._manager = get_manager(environment, mode, dry_run=dry_run)
219
+ state._manager = get_manager(environment, mode, dry_run=dry_run, commands=commands)
@@ -10,6 +10,10 @@ Examples:
10
10
  mantis -e production deploy --dirty
11
11
  mantis -e production build + push + deploy
12
12
  mantis -e production build web api + push + deploy
13
+ mantis -e prod manage migrate --fake
14
+ mantis -e prod pg-dump --data-only --table users
15
+ mantis -e prod bash web
16
+ mantis -e prod logs django
13
17
  mantis status (single connection mode)
14
18
  mantis manage migrate
15
19
  """
@@ -20,12 +24,15 @@ import click
20
24
  import typer
21
25
 
22
26
  from mantis import VERSION
23
- from mantis.app import app, state
27
+ from mantis.app import app, state, register_shortcuts
24
28
  from mantis.managers import get_manager
25
29
 
26
30
  # Import commands to register them with the app
27
31
  from mantis import commands # noqa: F401
28
32
 
33
+ # Register shortcuts after all commands (so they appear at end of help)
34
+ register_shortcuts()
35
+
29
36
  # Command separator for chaining
30
37
  COMMAND_SEPARATOR = '+'
31
38
 
@@ -174,9 +181,11 @@ def run():
174
181
 
175
182
  # Multiple commands - parse options and initialize state manually
176
183
  opts = parse_global_options(global_opts)
184
+ # Collect all command names from all groups
185
+ all_commands = [group[0] for group in cmd_groups if group]
177
186
  state._mode = opts['mode']
178
187
  state._dry_run = opts['dry_run']
179
- state._manager = get_manager(opts['env'], opts['mode'], dry_run=opts['dry_run'])
188
+ state._manager = get_manager(opts['env'], opts['mode'], dry_run=opts['dry_run'], commands=all_commands)
180
189
 
181
190
  # Get Click app from Typer
182
191
  click_app = typer.main.get_command(app)
@@ -5,8 +5,9 @@ from mantis.commands import (
5
5
  containers,
6
6
  compose,
7
7
  services,
8
- crypto,
9
- config,
8
+ secrets,
9
+ configuration,
10
+ connection,
10
11
  volumes,
11
12
  django,
12
13
  postgres,
@@ -19,8 +20,9 @@ __all__ = [
19
20
  'containers',
20
21
  'compose',
21
22
  'services',
22
- 'crypto',
23
- 'config',
23
+ 'secrets',
24
+ 'configuration',
25
+ 'connection',
24
26
  'volumes',
25
27
  'django',
26
28
  'postgres',
@@ -25,6 +25,7 @@ def down(
25
25
  @command(name="run", panel="Compose")
26
26
  def run_cmd(
27
27
  params: List[str] = typer.Argument(..., help="Compose run parameters"),
28
+ rm: bool = typer.Option(False, "--rm", help="Remove container after run"),
28
29
  ):
29
30
  """Calls compose run with params"""
30
- state.run(params=params)
31
+ state.run(params=params, rm=rm)
@@ -0,0 +1,16 @@
1
+ """Configuration commands: show-config, check-config."""
2
+ import json
3
+
4
+ from mantis.app import command, state
5
+
6
+
7
+ @command(name="show-config", panel="Configuration", no_env=True)
8
+ def show_config():
9
+ """Shows the JSON mantis config"""
10
+ print(json.dumps(state._manager.config, indent=2))
11
+
12
+
13
+ @command(name="check-config", panel="Configuration", no_env=True)
14
+ def check_config():
15
+ """Validates config file"""
16
+ state.check_config()
@@ -1,13 +1,7 @@
1
- """Config commands: check-config, contexts, create-context, ssh."""
1
+ """Connection commands: contexts, create-context, ssh."""
2
2
  from mantis.app import command, state
3
3
 
4
4
 
5
- @command(name="check-config", no_env=True)
6
- def check_config():
7
- """Validates config file"""
8
- state.check_config()
9
-
10
-
11
5
  @command(panel="Connections", no_env=True)
12
6
  def contexts():
13
7
  """Prints all docker contexts"""
@@ -16,12 +16,20 @@ def shell():
16
16
  def manage(
17
17
  cmd: str = typer.Argument(..., help="Django management command"),
18
18
  args: Optional[List[str]] = typer.Argument(None, help="Command arguments"),
19
+ if_healthy: bool = typer.Option(False, "--if-healthy", help="Only execute if container is healthy"),
20
+ healthy_timeout: Optional[int] = typer.Option(None, "--healthy-timeout", help="Wait up to N seconds for container to become healthy"),
19
21
  ):
20
22
  """Runs Django manage command"""
21
- state.manage(cmd=cmd, args=args)
23
+ state.manage(cmd=cmd, args=args, if_healthy=if_healthy, healthy_timeout=healthy_timeout)
22
24
 
23
25
 
24
26
  @command(name="send-test-email", panel="Django")
25
27
  def send_test_email():
26
28
  """Sends test email to admins"""
27
29
  state.send_test_email()
30
+
31
+
32
+ @command(name="reset-migrations", panel="Django")
33
+ def reset_migrations():
34
+ """Clears migration history and fakes all migrations"""
35
+ state.reset_migrations()