0
# CLI Commands
1
2
Complete command-line interface for Open edX deployment and management. Tutor provides a comprehensive CLI that supports local development, production deployment, configuration management, plugin administration, and Docker image building.
3
4
## Capabilities
5
6
### Main CLI Entry Point
7
8
The primary CLI entry point that dynamically loads commands including plugin-provided commands.
9
10
```python { .api }
11
def main() -> None:
12
"""
13
Main CLI entry point. Initializes hooks system and handles global exceptions.
14
"""
15
16
class TutorCli(click.Group):
17
"""
18
Dynamically load subcommands at runtime including plugin commands.
19
"""
20
def get_command(self, ctx: click.Context, cmd_name: str) -> Optional[click.Command]: ...
21
def list_commands(self, ctx: click.Context) -> list[str]: ...
22
23
@click.group(cls=TutorCli)
24
@click.version_option()
25
@click.option("-r", "--root", envvar="TUTOR_ROOT", type=click.Path(resolve_path=True))
26
@click.option("-h", "--help", "show_help", is_flag=True)
27
def cli(context: click.Context, root: str, show_help: bool) -> None:
28
"""
29
Main CLI group command with global options for project root and help.
30
"""
31
```
32
33
### Configuration Commands
34
35
Manage Open edX platform configuration including interactive setup, value printing, and patch management.
36
37
```python { .api }
38
@click.group(name="config")
39
def config_command(): ...
40
41
@click.command()
42
@click.option("--interactive", "-i", is_flag=True)
43
@click.option("--set", "set_vars", multiple=True, type=ConfigKeyValParamType())
44
@click.option("--append", "append_vars", multiple=True, type=ConfigListKeyValParamType())
45
@click.option("--remove", "remove_vars", multiple=True, type=ConfigListKeyValParamType())
46
@click.option("--unset", "unset_vars", multiple=True)
47
@click.option("--env-only", is_flag=True)
48
@click.option("--clean-env", is_flag=True)
49
def save(context: Context, interactive: bool, set_vars: list[tuple[str, Any]],
50
append_vars: list[tuple[str, Any]], remove_vars: list[tuple[str, Any]],
51
unset_vars: list[str], env_only: bool, clean_env: bool) -> None:
52
"""
53
Create and save configuration interactively or with specified values.
54
"""
55
56
@click.command()
57
def printroot(context: Context) -> None:
58
"""
59
Print the project root directory.
60
"""
61
62
@click.command()
63
@click.argument("key")
64
def printvalue(context: Context, key: str) -> None:
65
"""
66
Print a specific configuration value.
67
"""
68
69
@click.command()
70
def edit(context: Context) -> None:
71
"""
72
Edit config.yml in the default text editor.
73
"""
74
75
@click.group()
76
def patches(): ...
77
78
@click.command(name="list")
79
def patches_list(context: Context) -> None:
80
"""
81
Print available template patches.
82
"""
83
84
@click.command()
85
@click.argument("name")
86
def patches_show(context: Context, name: str) -> None:
87
"""
88
Print the rendered contents of a specific patch.
89
"""
90
```
91
92
### Local Development Commands
93
94
Run Open edX locally with Docker Compose for development and testing.
95
96
```python { .api }
97
@click.group()
98
def local(): ...
99
100
@click.command()
101
@click.option("--non-interactive", is_flag=True)
102
@click.option("--pullimages", is_flag=True)
103
@click.option("--skip-build", is_flag=True)
104
def launch(context: Context, non_interactive: bool, pullimages: bool, skip_build: bool) -> None:
105
"""
106
Configure and run Open edX from scratch in local mode.
107
"""
108
109
@click.command()
110
def start(context: Context) -> None:
111
"""
112
Start Open edX platform services.
113
"""
114
115
@click.command()
116
def stop(context: Context) -> None:
117
"""
118
Stop Open edX platform services.
119
"""
120
121
@click.command()
122
def restart(context: Context) -> None:
123
"""
124
Restart Open edX platform services.
125
"""
126
127
@click.command()
128
def status(context: Context) -> None:
129
"""
130
Display status of all services.
131
"""
132
133
@click.command()
134
@click.argument("services", nargs=-1)
135
def logs(context: Context, services: tuple[str, ...]) -> None:
136
"""
137
View logs from services.
138
"""
139
```
140
141
### Development Mode Commands
142
143
Run Open edX with development settings for rapid iteration and debugging.
144
145
```python { .api }
146
@click.group()
147
def dev(): ...
148
149
@click.command()
150
def hosts(context: Context) -> None:
151
"""
152
List status of all services with their URLs.
153
"""
154
155
# All local commands are also available in dev mode
156
# (launch, start, stop, restart, status, logs, etc.)
157
```
158
159
### Kubernetes Commands
160
161
Deploy and manage Open edX on Kubernetes with kubectl integration.
162
163
```python { .api }
164
@click.group()
165
def k8s(): ...
166
167
@click.command()
168
@click.option("--non-interactive", is_flag=True)
169
@click.option("--pullimages", is_flag=True)
170
@click.option("--skip-build", is_flag=True)
171
def launch(context: Context, non_interactive: bool, pullimages: bool, skip_build: bool) -> None:
172
"""
173
Configure and run Open edX from scratch on Kubernetes.
174
"""
175
176
@click.command()
177
def start(context: Context) -> None:
178
"""
179
Start Open edX platform on Kubernetes.
180
"""
181
182
@click.command()
183
def stop(context: Context) -> None:
184
"""
185
Stop Open edX platform on Kubernetes.
186
"""
187
188
@click.command()
189
@click.argument("services", nargs=-1)
190
def logs(context: Context, services: tuple[str, ...]) -> None:
191
"""
192
View logs from Kubernetes pods.
193
"""
194
195
@click.command()
196
@click.argument("service")
197
@click.argument("command", nargs=-1)
198
def exec(context: Context, service: str, command: tuple[str, ...]) -> None:
199
"""
200
Execute command in a Kubernetes pod.
201
"""
202
```
203
204
### Plugin Management Commands
205
206
Install, enable, disable, and manage Tutor plugins including discovery and configuration.
207
208
```python { .api }
209
@click.group()
210
def plugins_command(): ...
211
212
@click.command(name="list")
213
def list_plugins(context: Context) -> None:
214
"""
215
List installed plugins with their status.
216
"""
217
218
@click.command()
219
@click.argument("plugin_names", nargs=-1, type=PluginName())
220
def enable(context: Context, plugin_names: tuple[str, ...]) -> None:
221
"""
222
Enable one or more plugins.
223
"""
224
225
@click.command()
226
@click.argument("plugin_names", nargs=-1, type=PluginName())
227
def disable(context: Context, plugin_names: tuple[str, ...]) -> None:
228
"""
229
Disable one or more plugins.
230
"""
231
232
@click.command()
233
@click.argument("plugin_names", nargs=-1, type=IndexPluginName())
234
def install(context: Context, plugin_names: tuple[str, ...]) -> None:
235
"""
236
Install plugins from plugin indexes or Git repositories.
237
"""
238
239
@click.command()
240
@click.argument("plugin_names", nargs=-1, type=PluginName())
241
def uninstall(context: Context, plugin_names: tuple[str, ...]) -> None:
242
"""
243
Uninstall plugins.
244
"""
245
```
246
247
### Image Management Commands
248
249
Build, pull, and push Docker images for Open edX services and plugins.
250
251
```python { .api }
252
@click.group()
253
def images_command(): ...
254
255
@click.command()
256
@click.argument("image_names", nargs=-1)
257
@click.option("--target", multiple=True)
258
@click.option("--build-arg", multiple=True)
259
@click.option("--add-host", multiple=True)
260
@click.option("--build-context", multiple=True)
261
def build(context: Context, image_names: tuple[str, ...], target: tuple[str, ...],
262
build_arg: tuple[str, ...], add_host: tuple[str, ...],
263
build_context: tuple[str, ...]) -> None:
264
"""
265
Build Docker images for specified services.
266
"""
267
268
@click.command()
269
@click.argument("image_names", nargs=-1)
270
def pull(context: Context, image_names: tuple[str, ...]) -> None:
271
"""
272
Pull Docker images for specified services.
273
"""
274
275
@click.command()
276
@click.argument("image_names", nargs=-1)
277
def push(context: Context, image_names: tuple[str, ...]) -> None:
278
"""
279
Push Docker images for specified services.
280
"""
281
```
282
283
### Mount Management Commands
284
285
Manage bind mounts for development workflows.
286
287
```python { .api }
288
@click.group()
289
def mounts_command(): ...
290
291
@click.command(name="list")
292
def list_mounts(context: Context) -> None:
293
"""
294
List current bind mount configuration.
295
"""
296
297
@click.command()
298
@click.argument("service")
299
@click.argument("host_path")
300
@click.argument("container_path")
301
def add(context: Context, service: str, host_path: str, container_path: str) -> None:
302
"""
303
Add a bind mount for a service.
304
"""
305
306
@click.command()
307
@click.argument("service")
308
@click.argument("container_path")
309
def remove(context: Context, service: str, container_path: str) -> None:
310
"""
311
Remove a bind mount for a service.
312
"""
313
```
314
315
## Parameter Types
316
317
```python { .api }
318
class PluginName(click.ParamType):
319
"""
320
Click parameter type for plugin names with auto-completion.
321
"""
322
def convert(self, value: str, param: Optional[click.Parameter], ctx: Optional[click.Context]) -> str: ...
323
324
class IndexPluginName(click.ParamType):
325
"""
326
Click parameter type for plugin names from indexes with auto-completion.
327
"""
328
def convert(self, value: str, param: Optional[click.Parameter], ctx: Optional[click.Context]) -> str: ...
329
330
class ConfigKeyValParamType(click.ParamType):
331
"""
332
Parser for <KEY>=<YAML VALUE> command line arguments.
333
"""
334
def convert(self, value: str, param: Any, ctx: Any) -> tuple[str, Any]: ...
335
336
class ConfigListKeyValParamType(ConfigKeyValParamType):
337
"""
338
Same as ConfigKeyValParamType but for keys of type list.
339
"""
340
pass
341
```
342
343
## Usage Examples
344
345
### Basic Deployment
346
347
```bash
348
# Initialize configuration interactively
349
tutor config save --interactive
350
351
# Launch locally
352
tutor local launch
353
354
# Check status
355
tutor local status
356
357
# View logs
358
tutor local logs lms cms
359
```
360
361
### Plugin Management
362
363
```bash
364
# List available plugins
365
tutor plugins list
366
367
# Install and enable a plugin
368
tutor plugins install discovery
369
tutor plugins enable discovery
370
371
# Rebuild configuration with plugin
372
tutor config save
373
```
374
375
### Kubernetes Deployment
376
377
```bash
378
# Configure for Kubernetes
379
tutor config save --set K8S_NAMESPACE=openedx
380
381
# Deploy to Kubernetes
382
tutor k8s launch
383
384
# Check pod status
385
tutor k8s status
386
```