Extend CLI extension loader to support multiple target types#56
Open
tomdurrant wants to merge 1 commit into
Open
Extend CLI extension loader to support multiple target types#56tomdurrant wants to merge 1 commit into
tomdurrant wants to merge 1 commit into
Conversation
Add support for three extension styles in the oceanum CLI host: - Legacy module side effects (existing behaviour, unchanged) - Direct click.Command/Group export - Registrar callable (receives parent group, registers commands) Broken plugins are caught and logged to stderr without aborting startup. An OCEANUM_CLI_DEBUG env var enables verbose load tracing. Also normalise the token-gated test bootstrap: conftest.py uses pytest hooks to skip requires_datamesh_token tests when the env var is absent, and test_cli_storage.py is marked accordingly. Add unit tests covering all four dispatch paths plus broken-plugin resilience and debug-mode safety.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactors the
oceanumCLI entry point to support three plugin extension styles — legacy module side-effects, directclick.Command/click.Groupexports, and registrar callables — while remaining fully backward-compatible with existing built-in extensions.Changes
src/oceanum/__main__.py: Extractedload_cli_extensions(parent_group)function with type-dispatch on entry point return values:types.ModuleType→ legacy import side-effects (unchanged behaviour)click.Command/click.Group→ registered directly onto the parent groupep_obj(parent_group)OCEANUM_CLI_DEBUG=1enables verbose load tracingtests/test_cli_extension_loader.py: New unit tests covering all four dispatch paths, broken-plugin resilience, and debug-mode safety (5 tests, no network required)tests/conftest.py+tests/test_cli_storage.py: Token-gated test bootstrap normalised —requires_datamesh_tokenmarker skips storage tests whenOCEANUM_TEST_DATAMESH_TOKENis absentpyproject.toml:requires_datamesh_tokenpytest marker registeredREADME.md: Plugin Authoring section added with examples of all three target stylesTesting
All local/unit tests pass without a live token: