Add CLI command development guide to CONTRIBUTING.md
This commit is contained in:
parent
0fe9fa6543
commit
e414cf266a
1 changed files with 45 additions and 0 deletions
|
|
@ -230,6 +230,51 @@ src/
|
||||||
```
|
```
|
||||||
3. Update README.md keyboard shortcuts table
|
3. Update README.md keyboard shortcuts table
|
||||||
|
|
||||||
|
### Adding a New CLI Command
|
||||||
|
|
||||||
|
The interactive terminal supports custom CLI commands for Roblox development.
|
||||||
|
|
||||||
|
1. Edit `src/lib/cli-commands.ts`
|
||||||
|
2. Add your command to the `commands` object:
|
||||||
|
```typescript
|
||||||
|
mycommand: {
|
||||||
|
name: 'mycommand',
|
||||||
|
description: 'Description of what it does',
|
||||||
|
usage: 'mycommand [args]',
|
||||||
|
aliases: ['mc', 'mycmd'], // Optional
|
||||||
|
execute: async (args, context) => {
|
||||||
|
// Access current code, files, etc. from context
|
||||||
|
// context.currentCode
|
||||||
|
// context.currentFile
|
||||||
|
// context.files
|
||||||
|
// context.setCode()
|
||||||
|
// context.addLog()
|
||||||
|
|
||||||
|
// Perform your command logic
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
output: 'Command output',
|
||||||
|
type: 'info', // or 'log', 'warn', 'error'
|
||||||
|
};
|
||||||
|
},
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Available Context:
|
||||||
|
- `context.currentCode` - Current editor code
|
||||||
|
- `context.currentFile` - Active file name
|
||||||
|
- `context.files` - File tree array
|
||||||
|
- `context.setCode(code)` - Update editor code
|
||||||
|
- `context.addLog(message, type)` - Add terminal log
|
||||||
|
|
||||||
|
#### Command Features:
|
||||||
|
- Command aliases for shortcuts
|
||||||
|
- Argument parsing (args array)
|
||||||
|
- Context-aware execution
|
||||||
|
- Error handling with toast notifications
|
||||||
|
- Special `__CLEAR__` output to clear terminal
|
||||||
|
|
||||||
## Performance Guidelines
|
## Performance Guidelines
|
||||||
|
|
||||||
- Use React.lazy() for code splitting
|
- Use React.lazy() for code splitting
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue