0
# CLI Commands
1
2
Indico provides a comprehensive command-line interface for administrative operations, database management, user administration, and system maintenance. The CLI is the primary interface for server administration and deployment operations.
3
4
## Capabilities
5
6
### Core CLI Framework
7
8
The foundation for all Indico CLI commands, providing decorators and utilities for creating command groups and individual commands.
9
10
```python { .api }
11
def cli():
12
"""Main CLI group function and entry point."""
13
14
def cli_command(name=None, **attrs):
15
"""
16
Decorator for creating CLI commands.
17
18
Parameters:
19
- name: str, optional command name (defaults to function name)
20
- **attrs: additional click command attributes
21
22
Returns:
23
Decorated command function
24
"""
25
26
def cli_group(name=None, **attrs):
27
"""
28
Decorator for creating CLI command groups.
29
30
Parameters:
31
- name: str, optional group name (defaults to function name)
32
- **attrs: additional click group attributes
33
34
Returns:
35
Decorated group function
36
"""
37
```
38
39
### Database Management
40
41
Commands for database initialization, migration, and maintenance operations.
42
43
```python { .api }
44
def prepare():
45
"""
46
Initialize new database.
47
Creates tables and sets alembic revision to HEAD.
48
"""
49
50
def reset_alembic():
51
"""
52
Reset alembic state from 1.9.x upgrades.
53
Used for database migration recovery.
54
"""
55
```
56
57
Usage examples:
58
59
```bash
60
# Initialize a fresh database
61
indico db prepare
62
63
# Reset alembic state after upgrade issues
64
indico db reset-alembic
65
66
# Run database migrations
67
indico db upgrade
68
69
# Downgrade database
70
indico db downgrade
71
```
72
73
### User Management
74
75
Administrative commands for user account management and administration.
76
77
```bash
78
# Create a new user account
79
indico user create user@example.com
80
81
# List all users
82
indico user list
83
84
# Grant admin privileges
85
indico user grant-admin user@example.com
86
87
# Reset user password
88
indico user reset-password user@example.com
89
```
90
91
### Event Management
92
93
Commands for event lifecycle management and administration.
94
95
```bash
96
# List events
97
indico event list
98
99
# Export event data
100
indico event export 123
101
102
# Clean up old events
103
indico event cleanup --days 365
104
```
105
106
### Internationalization
107
108
Translation and localization management commands for both core Indico and plugins.
109
110
```python { .api }
111
def compile():
112
"""
113
Catalog compilation for Indico and plugins.
114
Compiles .po files to .mo files for runtime use.
115
"""
116
117
def extract():
118
"""
119
Message extraction for Indico and plugins.
120
Extracts translatable strings from source code.
121
"""
122
123
def init():
124
"""
125
New catalog initialization for Indico and plugins.
126
Creates new translation files for specified languages.
127
"""
128
129
def update():
130
"""
131
Catalog merging for Indico and plugins.
132
Updates existing translation files with new strings.
133
"""
134
135
def push():
136
"""
137
Push .pot files to Transifex.
138
Uploads source translation files to the translation service.
139
"""
140
141
def pull():
142
"""
143
Pull translated .po files from Transifex.
144
Downloads completed translations from the service.
145
"""
146
```
147
148
Usage examples:
149
150
```bash
151
# Extract translatable strings
152
indico i18n extract
153
154
# Compile translation catalogs
155
indico i18n compile
156
157
# Initialize new language
158
indico i18n init --locale de_DE
159
160
# Update existing translations
161
indico i18n update
162
163
# Push to Transifex
164
indico i18n push
165
166
# Pull from Transifex
167
indico i18n pull
168
```
169
170
### System Maintenance
171
172
Commands for system cleanup, maintenance, and administrative tasks.
173
174
```bash
175
# Clean up temporary files
176
indico maintenance cleanup
177
178
# Rebuild search index
179
indico maintenance rebuild-index
180
181
# Generate statistical reports
182
indico maintenance stats
183
184
# Clean up orphaned files
185
indico maintenance clean-files
186
```
187
188
## Command Development
189
190
To create custom CLI commands for plugins or extensions:
191
192
```python
193
from indico.cli.core import cli_command, cli_group
194
195
@cli_group()
196
def my_plugin():
197
"""My plugin commands."""
198
199
@my_plugin.command()
200
@cli_command
201
def my_command():
202
"""Custom command for my plugin."""
203
click.echo("Hello from my plugin!")
204
```
205
206
## Entry Point
207
208
All CLI commands are accessible through the main `indico` entry point defined in the package configuration:
209
210
```toml
211
[project.scripts]
212
indico = "indico.cli.core:cli"
213
```