deepctl-plugin-example 0.1.0__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.
- deepctl_plugin_example-0.1.0/PKG-INFO +147 -0
- deepctl_plugin_example-0.1.0/README.md +127 -0
- deepctl_plugin_example-0.1.0/pyproject.toml +33 -0
- deepctl_plugin_example-0.1.0/setup.cfg +4 -0
- deepctl_plugin_example-0.1.0/src/deepctl_plugin_example/__init__.py +6 -0
- deepctl_plugin_example-0.1.0/src/deepctl_plugin_example/command.py +161 -0
- deepctl_plugin_example-0.1.0/src/deepctl_plugin_example/models.py +13 -0
- deepctl_plugin_example-0.1.0/src/deepctl_plugin_example.egg-info/PKG-INFO +147 -0
- deepctl_plugin_example-0.1.0/src/deepctl_plugin_example.egg-info/SOURCES.txt +11 -0
- deepctl_plugin_example-0.1.0/src/deepctl_plugin_example.egg-info/dependency_links.txt +1 -0
- deepctl_plugin_example-0.1.0/src/deepctl_plugin_example.egg-info/entry_points.txt +2 -0
- deepctl_plugin_example-0.1.0/src/deepctl_plugin_example.egg-info/requires.txt +3 -0
- deepctl_plugin_example-0.1.0/src/deepctl_plugin_example.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: deepctl-plugin-example
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Example plugin for deepctl
|
|
5
|
+
Author-email: Deepgram <devrel@deepgram.com>
|
|
6
|
+
Maintainer-email: Deepgram <devrel@deepgram.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Keywords: deepgram,cli,plugin,example
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
Requires-Dist: deepctl-core
|
|
18
|
+
Requires-Dist: click>=8.0.0
|
|
19
|
+
Requires-Dist: rich>=13.0.0
|
|
20
|
+
|
|
21
|
+
# deepctl Plugin Example
|
|
22
|
+
|
|
23
|
+
An example plugin for deepctl demonstrating how to create and distribute custom commands as separate packages.
|
|
24
|
+
|
|
25
|
+
## Overview
|
|
26
|
+
|
|
27
|
+
This plugin shows how to extend deepctl with custom commands that can be:
|
|
28
|
+
|
|
29
|
+
- Developed independently
|
|
30
|
+
- Distributed via PyPI
|
|
31
|
+
- Installed alongside the CLI
|
|
32
|
+
- Discovered automatically at runtime
|
|
33
|
+
|
|
34
|
+
**Note:** This plugin is NOT a dependency of deepctl. It must be installed separately to demonstrate how the plugin system works for third-party developers. This example plugin is published to PyPI with each deepctl release to ensure the documentation is always testable.
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
### Development Installation
|
|
39
|
+
|
|
40
|
+
To install the plugin in development mode:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# From the plugin directory
|
|
44
|
+
pip install -e .
|
|
45
|
+
|
|
46
|
+
# Or using uv
|
|
47
|
+
uv pip install -e .
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Production Installation
|
|
51
|
+
|
|
52
|
+
For users who have deepctl installed globally:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Recommended: Using pipx (if deepctl was installed with pipx)
|
|
56
|
+
pipx install deepctl # If not already installed
|
|
57
|
+
pipx inject deepctl deepctl-plugin-example
|
|
58
|
+
|
|
59
|
+
# Alternative: Using pip (only works in development environments)
|
|
60
|
+
pip install deepctl deepctl-plugin-example
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Note:** If you installed deepctl with `uv tool install`, plugin installation requires manual workarounds. We recommend using pipx for the best plugin experience.
|
|
64
|
+
|
|
65
|
+
## Usage
|
|
66
|
+
|
|
67
|
+
Once installed, the plugin command becomes available in the CLI:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Basic usage
|
|
71
|
+
deepctl example
|
|
72
|
+
|
|
73
|
+
# Custom greeting
|
|
74
|
+
deepctl example --greeting "Howdy" --name "Partner"
|
|
75
|
+
|
|
76
|
+
# Show plugin system information
|
|
77
|
+
deepctl example --show-info
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## How It Works
|
|
81
|
+
|
|
82
|
+
1. **Entry Point Registration**: The plugin registers itself via the `deepctl.plugins` entry point in `pyproject.toml`
|
|
83
|
+
2. **Command Discovery**: The CLI's PluginManager discovers the plugin at runtime using `importlib.metadata`
|
|
84
|
+
3. **Command Loading**: The plugin's command class is instantiated and added to the CLI
|
|
85
|
+
4. **Execution**: When the user runs the command, the plugin's `handle()` method is called
|
|
86
|
+
|
|
87
|
+
## Creating Your Own Plugin
|
|
88
|
+
|
|
89
|
+
To create your own deepctl plugin:
|
|
90
|
+
|
|
91
|
+
1. **Copy this example package** as a starting point
|
|
92
|
+
2. **Rename the package** and update metadata in `pyproject.toml`
|
|
93
|
+
3. **Implement your command** by modifying the `command.py` file
|
|
94
|
+
4. **Define arguments** in the `get_arguments()` method
|
|
95
|
+
5. **Implement logic** in the `handle()` method
|
|
96
|
+
6. **Test locally** with `pip install -e .`
|
|
97
|
+
7. **Publish to PyPI** when ready
|
|
98
|
+
8. **Users install it** with `pipx inject deepctl your-plugin-name`
|
|
99
|
+
|
|
100
|
+
### Key Requirements
|
|
101
|
+
|
|
102
|
+
- Must inherit from `deepctl_core.BaseCommand`
|
|
103
|
+
- Must implement required properties: `name`, `help`
|
|
104
|
+
- Must implement `handle()` method
|
|
105
|
+
- Must be registered via entry point
|
|
106
|
+
|
|
107
|
+
### Example Command Structure
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from deepctl_core import BaseCommand
|
|
111
|
+
|
|
112
|
+
class MyCommand(BaseCommand):
|
|
113
|
+
name = "mycommand"
|
|
114
|
+
help = "Description of my command"
|
|
115
|
+
|
|
116
|
+
def handle(self, config, auth_manager, client, **kwargs):
|
|
117
|
+
# Your command logic here
|
|
118
|
+
pass
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Development
|
|
122
|
+
|
|
123
|
+
### Running Tests
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
uv run pytest
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Building the Package
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
python -m build
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Plugin Capabilities
|
|
136
|
+
|
|
137
|
+
Plugins have access to:
|
|
138
|
+
|
|
139
|
+
- Configuration management via `Config`
|
|
140
|
+
- Authentication via `AuthManager`
|
|
141
|
+
- Deepgram API client via `DeepgramClient`
|
|
142
|
+
- Rich terminal output via `rich`
|
|
143
|
+
- Command-line argument parsing via `click`
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
MIT
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# deepctl Plugin Example
|
|
2
|
+
|
|
3
|
+
An example plugin for deepctl demonstrating how to create and distribute custom commands as separate packages.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This plugin shows how to extend deepctl with custom commands that can be:
|
|
8
|
+
|
|
9
|
+
- Developed independently
|
|
10
|
+
- Distributed via PyPI
|
|
11
|
+
- Installed alongside the CLI
|
|
12
|
+
- Discovered automatically at runtime
|
|
13
|
+
|
|
14
|
+
**Note:** This plugin is NOT a dependency of deepctl. It must be installed separately to demonstrate how the plugin system works for third-party developers. This example plugin is published to PyPI with each deepctl release to ensure the documentation is always testable.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
### Development Installation
|
|
19
|
+
|
|
20
|
+
To install the plugin in development mode:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# From the plugin directory
|
|
24
|
+
pip install -e .
|
|
25
|
+
|
|
26
|
+
# Or using uv
|
|
27
|
+
uv pip install -e .
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Production Installation
|
|
31
|
+
|
|
32
|
+
For users who have deepctl installed globally:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Recommended: Using pipx (if deepctl was installed with pipx)
|
|
36
|
+
pipx install deepctl # If not already installed
|
|
37
|
+
pipx inject deepctl deepctl-plugin-example
|
|
38
|
+
|
|
39
|
+
# Alternative: Using pip (only works in development environments)
|
|
40
|
+
pip install deepctl deepctl-plugin-example
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Note:** If you installed deepctl with `uv tool install`, plugin installation requires manual workarounds. We recommend using pipx for the best plugin experience.
|
|
44
|
+
|
|
45
|
+
## Usage
|
|
46
|
+
|
|
47
|
+
Once installed, the plugin command becomes available in the CLI:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Basic usage
|
|
51
|
+
deepctl example
|
|
52
|
+
|
|
53
|
+
# Custom greeting
|
|
54
|
+
deepctl example --greeting "Howdy" --name "Partner"
|
|
55
|
+
|
|
56
|
+
# Show plugin system information
|
|
57
|
+
deepctl example --show-info
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## How It Works
|
|
61
|
+
|
|
62
|
+
1. **Entry Point Registration**: The plugin registers itself via the `deepctl.plugins` entry point in `pyproject.toml`
|
|
63
|
+
2. **Command Discovery**: The CLI's PluginManager discovers the plugin at runtime using `importlib.metadata`
|
|
64
|
+
3. **Command Loading**: The plugin's command class is instantiated and added to the CLI
|
|
65
|
+
4. **Execution**: When the user runs the command, the plugin's `handle()` method is called
|
|
66
|
+
|
|
67
|
+
## Creating Your Own Plugin
|
|
68
|
+
|
|
69
|
+
To create your own deepctl plugin:
|
|
70
|
+
|
|
71
|
+
1. **Copy this example package** as a starting point
|
|
72
|
+
2. **Rename the package** and update metadata in `pyproject.toml`
|
|
73
|
+
3. **Implement your command** by modifying the `command.py` file
|
|
74
|
+
4. **Define arguments** in the `get_arguments()` method
|
|
75
|
+
5. **Implement logic** in the `handle()` method
|
|
76
|
+
6. **Test locally** with `pip install -e .`
|
|
77
|
+
7. **Publish to PyPI** when ready
|
|
78
|
+
8. **Users install it** with `pipx inject deepctl your-plugin-name`
|
|
79
|
+
|
|
80
|
+
### Key Requirements
|
|
81
|
+
|
|
82
|
+
- Must inherit from `deepctl_core.BaseCommand`
|
|
83
|
+
- Must implement required properties: `name`, `help`
|
|
84
|
+
- Must implement `handle()` method
|
|
85
|
+
- Must be registered via entry point
|
|
86
|
+
|
|
87
|
+
### Example Command Structure
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from deepctl_core import BaseCommand
|
|
91
|
+
|
|
92
|
+
class MyCommand(BaseCommand):
|
|
93
|
+
name = "mycommand"
|
|
94
|
+
help = "Description of my command"
|
|
95
|
+
|
|
96
|
+
def handle(self, config, auth_manager, client, **kwargs):
|
|
97
|
+
# Your command logic here
|
|
98
|
+
pass
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Development
|
|
102
|
+
|
|
103
|
+
### Running Tests
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
uv run pytest
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Building the Package
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
python -m build
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Plugin Capabilities
|
|
116
|
+
|
|
117
|
+
Plugins have access to:
|
|
118
|
+
|
|
119
|
+
- Configuration management via `Config`
|
|
120
|
+
- Authentication via `AuthManager`
|
|
121
|
+
- Deepgram API client via `DeepgramClient`
|
|
122
|
+
- Rich terminal output via `rich`
|
|
123
|
+
- Command-line argument parsing via `click`
|
|
124
|
+
|
|
125
|
+
## License
|
|
126
|
+
|
|
127
|
+
MIT
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "deepctl-plugin-example"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Example plugin for deepctl"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
authors = [{ name = "Deepgram", email = "devrel@deepgram.com" }]
|
|
12
|
+
maintainers = [{ name = "Deepgram", email = "devrel@deepgram.com" }]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3.10",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
]
|
|
21
|
+
keywords = ["deepgram", "cli", "plugin", "example"]
|
|
22
|
+
requires-python = ">=3.10"
|
|
23
|
+
dependencies = ["deepctl-core", "click>=8.0.0", "rich>=13.0.0"]
|
|
24
|
+
|
|
25
|
+
[project.entry-points."deepctl.plugins"]
|
|
26
|
+
example = "deepctl_plugin_example.command:ExampleCommand"
|
|
27
|
+
|
|
28
|
+
[tool.setuptools]
|
|
29
|
+
package-dir = { "" = "src" }
|
|
30
|
+
|
|
31
|
+
[tool.setuptools.packages.find]
|
|
32
|
+
where = ["src"]
|
|
33
|
+
include = ["deepctl_plugin_example*"]
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"""Example plugin command for deepctl."""
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from deepctl_core import AuthManager, BaseCommand, Config, DeepgramClient
|
|
6
|
+
from rich.console import Console
|
|
7
|
+
from rich.panel import Panel
|
|
8
|
+
from rich.table import Table
|
|
9
|
+
|
|
10
|
+
console = Console()
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ExampleCommand(BaseCommand):
|
|
14
|
+
"""Example plugin command demonstrating the plugin system."""
|
|
15
|
+
|
|
16
|
+
name = "example"
|
|
17
|
+
help = "Example plugin command demonstrating the plugin system"
|
|
18
|
+
short_help = "Example plugin command"
|
|
19
|
+
|
|
20
|
+
# This example command doesn't require authentication
|
|
21
|
+
requires_auth = False
|
|
22
|
+
requires_project = False
|
|
23
|
+
ci_friendly = True
|
|
24
|
+
|
|
25
|
+
def get_arguments(self) -> list[dict[str, Any]]:
|
|
26
|
+
"""Get command arguments and options."""
|
|
27
|
+
return [
|
|
28
|
+
{
|
|
29
|
+
"names": ["--greeting", "-g"],
|
|
30
|
+
"help": "Custom greeting message",
|
|
31
|
+
"type": str,
|
|
32
|
+
"default": "Hello",
|
|
33
|
+
"required": False,
|
|
34
|
+
"is_option": True,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"names": ["--name", "-n"],
|
|
38
|
+
"help": "Name to greet",
|
|
39
|
+
"type": str,
|
|
40
|
+
"default": "World",
|
|
41
|
+
"required": False,
|
|
42
|
+
"is_option": True,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"names": ["--show-info"],
|
|
46
|
+
"help": "Show plugin system information",
|
|
47
|
+
"is_flag": True,
|
|
48
|
+
"is_option": True,
|
|
49
|
+
},
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
def handle(
|
|
53
|
+
self,
|
|
54
|
+
config: Config,
|
|
55
|
+
auth_manager: AuthManager,
|
|
56
|
+
client: DeepgramClient,
|
|
57
|
+
**kwargs: Any,
|
|
58
|
+
) -> Any:
|
|
59
|
+
"""Handle the example command."""
|
|
60
|
+
greeting = kwargs.get("greeting", "Hello")
|
|
61
|
+
name = kwargs.get("name", "World")
|
|
62
|
+
show_info = kwargs.get("show_info", False)
|
|
63
|
+
|
|
64
|
+
# Show plugin information if requested
|
|
65
|
+
if show_info:
|
|
66
|
+
# Display greeting
|
|
67
|
+
console.print(f"\n[bold blue]{greeting}, {name}![/bold blue]\n")
|
|
68
|
+
self._show_plugin_info()
|
|
69
|
+
# Return None to avoid additional output
|
|
70
|
+
return None
|
|
71
|
+
|
|
72
|
+
# For normal operation, return structured data for output formatting
|
|
73
|
+
# Don't print directly unless in help mode
|
|
74
|
+
if kwargs.get("help_mode", False):
|
|
75
|
+
self._show_help()
|
|
76
|
+
return None
|
|
77
|
+
|
|
78
|
+
# Return result for output formatting
|
|
79
|
+
from .models import ExampleResult
|
|
80
|
+
|
|
81
|
+
return ExampleResult(
|
|
82
|
+
message=f"{greeting}, {name}!",
|
|
83
|
+
plugin="deepctl-plugin-example",
|
|
84
|
+
version="0.1.0",
|
|
85
|
+
greeting=greeting,
|
|
86
|
+
name=name,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
def _show_help(self) -> None:
|
|
90
|
+
"""Show help information about the plugin."""
|
|
91
|
+
# Create help panel
|
|
92
|
+
help_content = """
|
|
93
|
+
This is an example plugin for deepctl demonstrating how to create
|
|
94
|
+
custom commands that integrate seamlessly with the CLI.
|
|
95
|
+
|
|
96
|
+
[bold]Usage:[/bold]
|
|
97
|
+
deepctl example [OPTIONS]
|
|
98
|
+
|
|
99
|
+
[bold]Options:[/bold]
|
|
100
|
+
-g, --greeting TEXT Custom greeting message [default: Hello]
|
|
101
|
+
-n, --name TEXT Name to greet [default: World]
|
|
102
|
+
--show-info Show plugin system information
|
|
103
|
+
|
|
104
|
+
[bold]Examples:[/bold]
|
|
105
|
+
# Basic usage
|
|
106
|
+
deepctl example
|
|
107
|
+
|
|
108
|
+
# Custom greeting
|
|
109
|
+
deepctl example --greeting "Howdy" --name "Partner"
|
|
110
|
+
|
|
111
|
+
# Show plugin info
|
|
112
|
+
deepctl example --show-info
|
|
113
|
+
"""
|
|
114
|
+
|
|
115
|
+
panel = Panel(
|
|
116
|
+
help_content.strip(),
|
|
117
|
+
title="[bold]Example Plugin Help[/bold]",
|
|
118
|
+
border_style="blue",
|
|
119
|
+
padding=(1, 2),
|
|
120
|
+
)
|
|
121
|
+
console.print(panel)
|
|
122
|
+
|
|
123
|
+
def _show_plugin_info(self) -> None:
|
|
124
|
+
"""Show information about the plugin system."""
|
|
125
|
+
console.print("[bold]Plugin System Information[/bold]\n")
|
|
126
|
+
|
|
127
|
+
# Create info table
|
|
128
|
+
table = Table(show_header=True, header_style="bold blue")
|
|
129
|
+
table.add_column("Property", style="cyan")
|
|
130
|
+
table.add_column("Value")
|
|
131
|
+
|
|
132
|
+
table.add_row("Plugin Name", "deepctl-plugin-example")
|
|
133
|
+
table.add_row("Version", "0.1.0")
|
|
134
|
+
table.add_row("Command Name", self.name)
|
|
135
|
+
table.add_row("Entry Point", "deepctl.commands")
|
|
136
|
+
table.add_row("Base Class", "deepctl_core.BaseCommand")
|
|
137
|
+
table.add_row("Requires Auth", str(self.requires_auth))
|
|
138
|
+
table.add_row("Requires Project", str(self.requires_project))
|
|
139
|
+
|
|
140
|
+
console.print(table)
|
|
141
|
+
console.print()
|
|
142
|
+
|
|
143
|
+
# Show how plugin loading works
|
|
144
|
+
info_panel = Panel(
|
|
145
|
+
"""[bold]How Plugin Loading Works:[/bold]
|
|
146
|
+
|
|
147
|
+
1. Plugins register via entry points in pyproject.toml
|
|
148
|
+
2. The CLI's PluginManager discovers them at runtime
|
|
149
|
+
3. Plugins must inherit from BaseCommand
|
|
150
|
+
4. When installed alongside the CLI, they become available
|
|
151
|
+
|
|
152
|
+
To create your own plugin:
|
|
153
|
+
- Copy this example package
|
|
154
|
+
- Modify the command class
|
|
155
|
+
- Update pyproject.toml metadata
|
|
156
|
+
- Install with: pip install -e ./your-plugin/""",
|
|
157
|
+
title="[bold]Plugin Development Guide[/bold]",
|
|
158
|
+
border_style="green",
|
|
159
|
+
padding=(1, 2),
|
|
160
|
+
)
|
|
161
|
+
console.print(info_panel)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Data models for the example plugin."""
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ExampleResult(BaseModel):
|
|
7
|
+
"""Result model for the example command."""
|
|
8
|
+
|
|
9
|
+
message: str
|
|
10
|
+
plugin: str
|
|
11
|
+
version: str
|
|
12
|
+
greeting: str | None = None
|
|
13
|
+
name: str | None = None
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: deepctl-plugin-example
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Example plugin for deepctl
|
|
5
|
+
Author-email: Deepgram <devrel@deepgram.com>
|
|
6
|
+
Maintainer-email: Deepgram <devrel@deepgram.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Keywords: deepgram,cli,plugin,example
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
Requires-Dist: deepctl-core
|
|
18
|
+
Requires-Dist: click>=8.0.0
|
|
19
|
+
Requires-Dist: rich>=13.0.0
|
|
20
|
+
|
|
21
|
+
# deepctl Plugin Example
|
|
22
|
+
|
|
23
|
+
An example plugin for deepctl demonstrating how to create and distribute custom commands as separate packages.
|
|
24
|
+
|
|
25
|
+
## Overview
|
|
26
|
+
|
|
27
|
+
This plugin shows how to extend deepctl with custom commands that can be:
|
|
28
|
+
|
|
29
|
+
- Developed independently
|
|
30
|
+
- Distributed via PyPI
|
|
31
|
+
- Installed alongside the CLI
|
|
32
|
+
- Discovered automatically at runtime
|
|
33
|
+
|
|
34
|
+
**Note:** This plugin is NOT a dependency of deepctl. It must be installed separately to demonstrate how the plugin system works for third-party developers. This example plugin is published to PyPI with each deepctl release to ensure the documentation is always testable.
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
### Development Installation
|
|
39
|
+
|
|
40
|
+
To install the plugin in development mode:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# From the plugin directory
|
|
44
|
+
pip install -e .
|
|
45
|
+
|
|
46
|
+
# Or using uv
|
|
47
|
+
uv pip install -e .
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Production Installation
|
|
51
|
+
|
|
52
|
+
For users who have deepctl installed globally:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Recommended: Using pipx (if deepctl was installed with pipx)
|
|
56
|
+
pipx install deepctl # If not already installed
|
|
57
|
+
pipx inject deepctl deepctl-plugin-example
|
|
58
|
+
|
|
59
|
+
# Alternative: Using pip (only works in development environments)
|
|
60
|
+
pip install deepctl deepctl-plugin-example
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Note:** If you installed deepctl with `uv tool install`, plugin installation requires manual workarounds. We recommend using pipx for the best plugin experience.
|
|
64
|
+
|
|
65
|
+
## Usage
|
|
66
|
+
|
|
67
|
+
Once installed, the plugin command becomes available in the CLI:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Basic usage
|
|
71
|
+
deepctl example
|
|
72
|
+
|
|
73
|
+
# Custom greeting
|
|
74
|
+
deepctl example --greeting "Howdy" --name "Partner"
|
|
75
|
+
|
|
76
|
+
# Show plugin system information
|
|
77
|
+
deepctl example --show-info
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## How It Works
|
|
81
|
+
|
|
82
|
+
1. **Entry Point Registration**: The plugin registers itself via the `deepctl.plugins` entry point in `pyproject.toml`
|
|
83
|
+
2. **Command Discovery**: The CLI's PluginManager discovers the plugin at runtime using `importlib.metadata`
|
|
84
|
+
3. **Command Loading**: The plugin's command class is instantiated and added to the CLI
|
|
85
|
+
4. **Execution**: When the user runs the command, the plugin's `handle()` method is called
|
|
86
|
+
|
|
87
|
+
## Creating Your Own Plugin
|
|
88
|
+
|
|
89
|
+
To create your own deepctl plugin:
|
|
90
|
+
|
|
91
|
+
1. **Copy this example package** as a starting point
|
|
92
|
+
2. **Rename the package** and update metadata in `pyproject.toml`
|
|
93
|
+
3. **Implement your command** by modifying the `command.py` file
|
|
94
|
+
4. **Define arguments** in the `get_arguments()` method
|
|
95
|
+
5. **Implement logic** in the `handle()` method
|
|
96
|
+
6. **Test locally** with `pip install -e .`
|
|
97
|
+
7. **Publish to PyPI** when ready
|
|
98
|
+
8. **Users install it** with `pipx inject deepctl your-plugin-name`
|
|
99
|
+
|
|
100
|
+
### Key Requirements
|
|
101
|
+
|
|
102
|
+
- Must inherit from `deepctl_core.BaseCommand`
|
|
103
|
+
- Must implement required properties: `name`, `help`
|
|
104
|
+
- Must implement `handle()` method
|
|
105
|
+
- Must be registered via entry point
|
|
106
|
+
|
|
107
|
+
### Example Command Structure
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from deepctl_core import BaseCommand
|
|
111
|
+
|
|
112
|
+
class MyCommand(BaseCommand):
|
|
113
|
+
name = "mycommand"
|
|
114
|
+
help = "Description of my command"
|
|
115
|
+
|
|
116
|
+
def handle(self, config, auth_manager, client, **kwargs):
|
|
117
|
+
# Your command logic here
|
|
118
|
+
pass
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Development
|
|
122
|
+
|
|
123
|
+
### Running Tests
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
uv run pytest
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Building the Package
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
python -m build
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Plugin Capabilities
|
|
136
|
+
|
|
137
|
+
Plugins have access to:
|
|
138
|
+
|
|
139
|
+
- Configuration management via `Config`
|
|
140
|
+
- Authentication via `AuthManager`
|
|
141
|
+
- Deepgram API client via `DeepgramClient`
|
|
142
|
+
- Rich terminal output via `rich`
|
|
143
|
+
- Command-line argument parsing via `click`
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
MIT
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/deepctl_plugin_example/__init__.py
|
|
4
|
+
src/deepctl_plugin_example/command.py
|
|
5
|
+
src/deepctl_plugin_example/models.py
|
|
6
|
+
src/deepctl_plugin_example.egg-info/PKG-INFO
|
|
7
|
+
src/deepctl_plugin_example.egg-info/SOURCES.txt
|
|
8
|
+
src/deepctl_plugin_example.egg-info/dependency_links.txt
|
|
9
|
+
src/deepctl_plugin_example.egg-info/entry_points.txt
|
|
10
|
+
src/deepctl_plugin_example.egg-info/requires.txt
|
|
11
|
+
src/deepctl_plugin_example.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
deepctl_plugin_example
|