diff --git a/docs/development.md b/docs/development.md index 5d512a6..5b1ce63 100644 --- a/docs/development.md +++ b/docs/development.md @@ -47,6 +47,9 @@ pobsync django check python3 manage.py showmigrations pobsync_backend ``` +The short `pobsync` aliases are limited to operational actions that are useful while debugging a running install. +Configuration aliases are intentionally not public commands; use the Django UI or explicit management commands instead. + Worker and scheduler commands are normally run by systemd services: ``` @@ -62,6 +65,14 @@ pobsync discover-snapshots --host pobsync retention ``` +For scripted configuration changes, call the Django management command explicitly so it is clear that this is an +automation/debugging path rather than the normal UI workflow: + +``` +pobsync django configure_pobsync_host --address +pobsync django configure_pobsync_schedule --cron "15 2 * * *" +``` + ## Installer Development The native installer is interactive by default when stdin is a terminal. It should keep every prompt backed by a command diff --git a/src/pobsync/cli.py b/src/pobsync/cli.py index 6bbdca3..46a7c8f 100644 --- a/src/pobsync/cli.py +++ b/src/pobsync/cli.py @@ -8,9 +8,6 @@ from django.core.management import execute_from_command_line COMMAND_ALIASES = { - "configure-global": "configure_pobsync_global", - "configure-host": "configure_pobsync_host", - "schedule": "configure_pobsync_schedule", "backup": "run_pobsync_backup", "retention": "run_pobsync_retention", "discover-snapshots": "discover_pobsync_snapshots", @@ -29,6 +26,9 @@ Usage: Commands: {commands} + +Configuration is managed from the Django control panel. Use +`pobsync django ` for automation or debugging. """ diff --git a/src/pobsync_backend/tests/test_console_entrypoint.py b/src/pobsync_backend/tests/test_console_entrypoint.py index 2584582..8baa148 100644 --- a/src/pobsync_backend/tests/test_console_entrypoint.py +++ b/src/pobsync_backend/tests/test_console_entrypoint.py @@ -31,15 +31,6 @@ class ConsoleEntrypointTests(SimpleTestCase): self.assertEqual(exit_code, 0) execute.assert_called_once_with(["pobsync", "check"]) - def test_maps_schedule_alias_to_django_command(self) -> None: - with patch("pobsync.cli.execute_from_command_line") as execute: - exit_code = main(["schedule", "web-01", "--cron", "15 2 * * *"]) - - self.assertEqual(exit_code, 0) - execute.assert_called_once_with( - ["pobsync", "configure_pobsync_schedule", "web-01", "--cron", "15 2 * * *"] - ) - def test_maps_discover_snapshots_alias_to_django_command(self) -> None: with patch("pobsync.cli.execute_from_command_line") as execute: exit_code = main(["discover-snapshots", "--host", "web-01"]) @@ -53,3 +44,12 @@ class ConsoleEntrypointTests(SimpleTestCase): self.assertEqual(exit_code, 0) execute.assert_called_once_with(["pobsync", "run_pobsync_worker", "--once"]) + + def test_configuration_aliases_are_not_public_commands(self) -> None: + stderr = StringIO() + with patch("sys.stderr", stderr): + exit_code = main(["schedule", "web-01", "--cron", "15 2 * * *"]) + + self.assertEqual(exit_code, 2) + self.assertIn("Unknown pobsync command", stderr.getvalue()) + self.assertIn("pobsync django ", stderr.getvalue())