|
| 1 | +--- |
| 2 | +title: CLI commands and flags |
| 3 | +description: CodeGate provides a command-line interface |
| 4 | +sidebar_position: 10 |
| 5 | +--- |
| 6 | + |
| 7 | +CodeGate provides a command-line interface through `cli.py` with the following |
| 8 | +structure: |
| 9 | + |
| 10 | +## Main command |
| 11 | + |
| 12 | +```bash |
| 13 | +codegate [OPTIONS] COMMAND [ARGS]... |
| 14 | +``` |
| 15 | + |
| 16 | +## Available commands |
| 17 | + |
| 18 | +### `serve` |
| 19 | + |
| 20 | +Start the CodeGate server: |
| 21 | + |
| 22 | +```bash |
| 23 | +codegate serve [OPTIONS] |
| 24 | +``` |
| 25 | + |
| 26 | +#### Options {#server-options} |
| 27 | + |
| 28 | +- `--port INTEGER`: Port to listen on (default: `8989`) |
| 29 | + - Must be between 1 and 65535 |
| 30 | + - Overrides configuration file and environment variables |
| 31 | +- `--host TEXT`: Host to bind to (default: `localhost`) |
| 32 | + - Overrides configuration file and environment variables |
| 33 | +- `--log-level [ERROR|WARNING|INFO|DEBUG]`: Set the log level (default: `INFO`) |
| 34 | + - Case-insensitive |
| 35 | + - Overrides configuration file and environment variables |
| 36 | +- `--log-format [JSON|TEXT]`: Set the log format (default: `JSON`) |
| 37 | + - Case-insensitive |
| 38 | + - Overrides configuration file and environment variables |
| 39 | +- `--config FILE`: Path to YAML config file |
| 40 | + |
| 41 | + - Optional |
| 42 | + - Must be a valid YAML file |
| 43 | + - Configuration values can be overridden by environment variables and CLI |
| 44 | + options |
| 45 | + |
| 46 | +- `--prompts FILE`: Path to YAML prompts file |
| 47 | + |
| 48 | + - Optional |
| 49 | + - Must be a valid YAML file |
| 50 | + - Overrides default prompts and configuration file prompts |
| 51 | + |
| 52 | +- `--vllm-url TEXT`: vLLM provider URL (default: `http://localhost:8000`) |
| 53 | + |
| 54 | + - Optional |
| 55 | + - Base URL for vLLM provider (/v1 path is added automatically) |
| 56 | + - Overrides configuration file and environment variables |
| 57 | + |
| 58 | +- `--openai-url TEXT`: OpenAI provider URL (default: |
| 59 | + `https://api.openai.com/v1`) |
| 60 | + |
| 61 | + - Optional |
| 62 | + - Base URL for OpenAI provider |
| 63 | + - Overrides configuration file and environment variables |
| 64 | + |
| 65 | +- `--anthropic-url TEXT`: Anthropic provider URL (default: |
| 66 | + `https://api.anthropic.com/v1`) |
| 67 | + |
| 68 | + - Optional |
| 69 | + - Base URL for Anthropic provider |
| 70 | + - Overrides configuration file and environment variables |
| 71 | + |
| 72 | +- `--ollama-url TEXT`: Ollama provider URL (default: `http://localhost:11434`) |
| 73 | + - Optional |
| 74 | + - Base URL for Ollama provider (/api path is added automatically) |
| 75 | + - Overrides configuration file and environment variables |
| 76 | + |
| 77 | +### `show-prompts` |
| 78 | + |
| 79 | +Display the loaded system prompts: |
| 80 | + |
| 81 | +```bash |
| 82 | +codegate show-prompts [OPTIONS] |
| 83 | +``` |
| 84 | + |
| 85 | +#### Options {#show-prompts-options} |
| 86 | + |
| 87 | +- `--prompts FILE`: Path to YAML prompts file |
| 88 | + - Optional |
| 89 | + - Must be a valid YAML file |
| 90 | + - If not provided, shows default prompts from [prompts/default.yaml](https://github.com/stacklok/codegate/blob/main/prompts/default.yaml) |
| 91 | + |
| 92 | +## Error handling |
| 93 | + |
| 94 | +The CLI provides user-friendly error messages for: |
| 95 | + |
| 96 | +- Invalid port numbers |
| 97 | +- Invalid log levels |
| 98 | +- Invalid log formats |
| 99 | +- Configuration file errors |
| 100 | +- Prompts file errors |
| 101 | +- Server startup failures |
| 102 | + |
| 103 | +All errors are output to stderr with appropriate exit codes. |
| 104 | + |
| 105 | +## Examples |
| 106 | + |
| 107 | +Start server with default settings: |
| 108 | + |
| 109 | +```bash |
| 110 | +codegate serve |
| 111 | +``` |
| 112 | + |
| 113 | +Start server on specific port and host: |
| 114 | + |
| 115 | +```bash |
| 116 | +codegate serve --port 8989 --host localhost |
| 117 | +``` |
| 118 | + |
| 119 | +Start server with custom logging: |
| 120 | + |
| 121 | +```bash |
| 122 | +codegate serve --log-level DEBUG --log-format TEXT |
| 123 | +``` |
| 124 | + |
| 125 | +Start server with configuration file: |
| 126 | + |
| 127 | +```bash |
| 128 | +codegate serve --config my-config.yaml |
| 129 | +``` |
| 130 | + |
| 131 | +Start server with custom prompts: |
| 132 | + |
| 133 | +```bash |
| 134 | +codegate serve --prompts my-prompts.yaml |
| 135 | +``` |
| 136 | + |
| 137 | +Start server with custom vLLM endpoint: |
| 138 | + |
| 139 | +```bash |
| 140 | +codegate serve --vllm-url https://vllm.example.com |
| 141 | +``` |
| 142 | + |
| 143 | +Start server with custom Ollama endpoint: |
| 144 | + |
| 145 | +```bash |
| 146 | +codegate serve --ollama-url http://localhost:11434 |
| 147 | +``` |
| 148 | + |
| 149 | +Show default system prompts: |
| 150 | + |
| 151 | +```bash |
| 152 | +codegate show-prompts |
| 153 | +``` |
| 154 | + |
| 155 | +Show prompts from a custom file: |
| 156 | + |
| 157 | +```bash |
| 158 | +codegate show-prompts --prompts my-prompts.yaml |
| 159 | +``` |
0 commit comments