huge refactor of the entire codebase, with the goal of improving maintainability, readability, and extensibility. This commit includes changes to almost every file in the project, including:
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""Example provider that uses the new `ResultTable` API.
|
||||
"""Example plugin that uses the new `ResultTable` API.
|
||||
|
||||
This module demonstrates a minimal provider adapter that yields `ResultModel`
|
||||
instances, a set of `ColumnSpec` definitions, and a tiny CLI-friendly renderer
|
||||
@@ -8,7 +8,7 @@ Run this to see sample output:
|
||||
python -m Provider.example_provider
|
||||
|
||||
Example usage (piped selector):
|
||||
provider-table -provider example -sample | select -select 1 | add-file -store default
|
||||
plugin-table -plugin example -sample | select -select 1 | add-file -store default
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -105,9 +105,9 @@ def selection_fn(row: ResultModel) -> List[str]:
|
||||
return ["-title", row.title]
|
||||
|
||||
|
||||
# Register the provider with the registry so callers can discover it by name
|
||||
from SYS.result_table_adapters import register_provider
|
||||
register_provider(
|
||||
# Register the plugin with the registry so callers can discover it by name
|
||||
from SYS.result_table_adapters import register_plugin
|
||||
register_plugin(
|
||||
"example",
|
||||
adapter,
|
||||
columns=columns_factory,
|
||||
@@ -223,17 +223,17 @@ def demo() -> None:
|
||||
|
||||
|
||||
def demo_with_selection(idx: int = 0) -> None:
|
||||
"""Demonstrate how a cmdlet would use provider registration and selection args.
|
||||
"""Demonstrate how a cmdlet would use plugin registration and selection args.
|
||||
|
||||
- Fetch the registered provider by name
|
||||
- Fetch the registered plugin by name
|
||||
- Build rows via adapter
|
||||
- Render the table
|
||||
- Show the selection args for the chosen row; these are the args a cmdlet
|
||||
would append when the user picks that row.
|
||||
"""
|
||||
from SYS.result_table_adapters import get_provider
|
||||
from SYS.result_table_adapters import get_plugin
|
||||
|
||||
provider = get_provider("example")
|
||||
provider = get_plugin("example")
|
||||
rows = list(provider.adapter(SAMPLE_ITEMS))
|
||||
cols = provider.get_columns(rows)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user