codemate-cli 1.0.0__py3-none-any.whl

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.
@@ -0,0 +1,298 @@
1
+ """
2
+ Help command implementation
3
+ """
4
+
5
+ from rich.console import Console
6
+ from rich.table import Table
7
+ from rich.panel import Panel
8
+ from rich.markdown import Markdown
9
+
10
+
11
+ class HelpCommand:
12
+ """Handler for help commands"""
13
+
14
+ def __init__(self, console: Console):
15
+ self.console = console
16
+
17
+ def show_welcome(self):
18
+ """Display welcome message"""
19
+ welcome_text = """
20
+ # Welcome to CodeMate CLI! 🎉
21
+
22
+ Your intelligent coding assistant powered by advanced AI.
23
+
24
+ ## Quick Start
25
+
26
+ 1. **Configure your API key:**
27
+ ```bash
28
+ codemate config set-key YOUR_API_KEY
29
+ ```
30
+
31
+ 2. **Start chatting:**
32
+ ```bash
33
+ codemate chat "How do I create a REST API?"
34
+ ```
35
+
36
+ 3. **Interactive mode:**
37
+ ```bash
38
+ codemate interactive
39
+ ```
40
+
41
+ Type `codemate --help` to see all available commands.
42
+ """
43
+ self.console.print(Markdown(welcome_text))
44
+
45
+ def show_commands_table(self):
46
+ """Display commands in a table"""
47
+ table = Table(
48
+ title="Available Commands",
49
+ show_header=True,
50
+ header_style="bold magenta"
51
+ )
52
+ table.add_column("Command", style="cyan", width=20)
53
+ table.add_column("Description", style="white")
54
+
55
+ commands = [
56
+ ("chat", "Send a one-off message to the AI"),
57
+ ("interactive", "Start an interactive chat session"),
58
+ ("config", "Manage configuration settings"),
59
+ ("models", "List available AI models"),
60
+ ("history", "View conversation history"),
61
+ ("clear", "Clear conversation history"),
62
+ ("--help", "Show help message"),
63
+ ("--version", "Show version information"),
64
+ ]
65
+
66
+ for cmd, desc in commands:
67
+ table.add_row(cmd, desc)
68
+
69
+ self.console.print(table)
70
+
71
+ def show_chat_help(self):
72
+ """Show help for chat command"""
73
+ help_text = """
74
+ ## Chat Command
75
+
76
+ Send a message to the AI assistant.
77
+
78
+ ### Usage
79
+
80
+ ```bash
81
+ codemate chat "Your message here"
82
+ ```
83
+
84
+ ### Options
85
+
86
+ - `--model, -m`: Specify the AI model to use
87
+ - `--stream / --no-stream`: Enable/disable streaming responses
88
+
89
+ ### Examples
90
+
91
+ **Basic chat:**
92
+ ```bash
93
+ codemate chat "Explain async/await in Python"
94
+ ```
95
+
96
+ **With specific model:**
97
+ ```bash
98
+ codemate chat --model openai/gpt-4 "Write a binary search algorithm"
99
+ ```
100
+
101
+ **Disable streaming:**
102
+ ```bash
103
+ codemate chat --no-stream "Your question"
104
+ ```
105
+ """
106
+ self.console.print(Markdown(help_text))
107
+
108
+ def show_interactive_help(self):
109
+ """Show help for interactive mode"""
110
+ help_text = """
111
+ ## Interactive Mode
112
+
113
+ Start a persistent conversation with the AI.
114
+
115
+ ### Usage
116
+
117
+ ```bash
118
+ codemate interactive
119
+ ```
120
+
121
+ ### Options
122
+
123
+ - `--model, -m`: Specify the AI model to use
124
+
125
+ ### Special Commands
126
+
127
+ While in interactive mode, you can use these commands:
128
+
129
+ - `/exit` or `/quit`: Exit interactive mode
130
+ - `/clear`: Clear conversation history
131
+ - `/help`: Show this help message
132
+ - `Ctrl+C`: Exit interactive mode
133
+
134
+ ### Example Session
135
+
136
+ ```bash
137
+ $ codemate interactive
138
+
139
+ [You] ❯ Write a function to calculate fibonacci numbers
140
+
141
+ [AI] Here's a function to calculate fibonacci numbers...
142
+
143
+ [You] ❯ Now add memoization
144
+
145
+ [AI] Here's the optimized version with memoization...
146
+
147
+ [You] ❯ /exit
148
+ Goodbye! 👋
149
+ ```
150
+ """
151
+ self.console.print(Markdown(help_text))
152
+
153
+ def show_config_help(self):
154
+ """Show help for config commands"""
155
+ help_text = """
156
+ ## Configuration Commands
157
+
158
+ Manage CodeMate CLI settings.
159
+
160
+ ### Commands
161
+
162
+ **Set API key:**
163
+ ```bash
164
+ codemate config set-key YOUR_API_KEY
165
+ ```
166
+
167
+ **View masked API key:**
168
+ ```bash
169
+ codemate config get-key
170
+ ```
171
+
172
+ **Set custom endpoint:**
173
+ ```bash
174
+ codemate config set-endpoint http://localhost:45223
175
+ ```
176
+
177
+ **View endpoint:**
178
+ ```bash
179
+ codemate config get-endpoint
180
+ ```
181
+
182
+ **Show all settings:**
183
+ ```bash
184
+ codemate config show
185
+ ```
186
+
187
+ **Reset to defaults:**
188
+ ```bash
189
+ codemate config reset
190
+ ```
191
+
192
+ ### Configuration File
193
+
194
+ Settings are stored in:
195
+ - **macOS/Linux:** `~/.config/codemate/config.json`
196
+ - **Windows:** `%APPDATA%\\CodeMate\\config.json`
197
+
198
+ ### Environment Variables
199
+
200
+ You can also configure via environment variables:
201
+ ```bash
202
+ export CODEMATE_API_KEY="your-api-key"
203
+ export CODEMATE_ENDPOINT="http://localhost:45223"
204
+ ```
205
+ """
206
+ self.console.print(Markdown(help_text))
207
+
208
+ def show_examples(self):
209
+ """Show usage examples"""
210
+ examples_text = """
211
+ ## Usage Examples
212
+
213
+ ### Code Generation
214
+
215
+ ```bash
216
+ codemate chat "Write a Python function to calculate fibonacci numbers"
217
+ ```
218
+
219
+ ### Code Explanation
220
+
221
+ ```bash
222
+ codemate chat "Explain this code: $(cat script.py)"
223
+ ```
224
+
225
+ ### Debugging Help
226
+
227
+ ```bash
228
+ codemate chat "I'm getting this error: ImportError: No module named 'requests'"
229
+ ```
230
+
231
+ ### Interactive Coding Session
232
+
233
+ ```bash
234
+ codemate interactive
235
+ ```
236
+
237
+ Then ask follow-up questions:
238
+ - "Now add error handling"
239
+ - "How do I test this?"
240
+ - "Refactor this to be more efficient"
241
+
242
+ ### Using Different Models
243
+
244
+ ```bash
245
+ codemate chat -m openai/gpt-4 "Complex question requiring advanced reasoning"
246
+ ```
247
+ """
248
+ self.console.print(Markdown(examples_text))
249
+
250
+ def show_troubleshooting(self):
251
+ """Show troubleshooting guide"""
252
+ troubleshooting_text = """
253
+ ## Troubleshooting
254
+
255
+ ### Connection Issues
256
+
257
+ **Problem:** Cannot connect to API server
258
+
259
+ **Solution:**
260
+ 1. Check if server is running: `curl http://localhost:45223`
261
+ 2. Verify endpoint: `codemate config show`
262
+ 3. Check network connectivity
263
+
264
+ ### Authentication Issues
265
+
266
+ **Problem:** API key not working
267
+
268
+ **Solution:**
269
+ 1. Verify key is set: `codemate config get-key`
270
+ 2. Check key is valid
271
+ 3. Try setting it again: `codemate config set-key YOUR_KEY`
272
+
273
+ ### Installation Issues
274
+
275
+ **Problem:** Command not found
276
+
277
+ **Solution:**
278
+ 1. Check installation: `pip show codemate-cli`
279
+ 2. Reinstall: `pip install --force-reinstall codemate-cli`
280
+ 3. Check PATH includes pip install location
281
+
282
+ ### Display Issues
283
+
284
+ **Problem:** Colors or formatting not working
285
+
286
+ **Solution:**
287
+ 1. Check terminal supports colors
288
+ 2. Try a different terminal
289
+ 3. Test rich: `python -m rich`
290
+
291
+ ### Getting Help
292
+
293
+ If issues persist:
294
+ 1. Check GitHub issues
295
+ 2. Run with verbose mode: `codemate -v chat "test"`
296
+ 3. Report bugs with error details
297
+ """
298
+ self.console.print(Markdown(troubleshooting_text))