Skip to content

Commit d18a71e

Browse files
Copilotshueybubbles
andcommitted
Split command sections into modern and legacy CLI in copilot-instructions.md
Co-authored-by: shueybubbles <2224906+shueybubbles@users.noreply.github.com>
1 parent c9de1df commit d18a71e

File tree

1 file changed

+40
-4
lines changed

1 file changed

+40
-4
lines changed

.github/copilot-instructions.md

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,48 @@ The project supports creating SQL Server instances using Docker or Podman:
178178

179179
## Common Tasks
180180

181-
### Adding a New Subcommand
181+
### Adding a New Command (Modern CLI)
182+
183+
For new commands related to context management, container operations, or configuration:
182184

183185
1. Create a new file in `cmd/modern/root/` (e.g., `mycommand.go`)
184-
2. Define the command struct and implement the `Run` method
185-
3. Register the command in the root command
186-
4. Add corresponding tests in `mycommand_test.go`
186+
2. Define a command struct that embeds `cmdparser.Cmd`
187+
3. Implement the `DefineCommand` method to set up command options, flags, and examples
188+
4. Implement the `run` method with the command logic
189+
5. Add corresponding tests in `mycommand_test.go`
190+
191+
Example structure:
192+
```go
193+
type MyCommand struct {
194+
cmdparser.Cmd
195+
// flags
196+
}
197+
198+
func (c *MyCommand) DefineCommand(...cmdparser.CommandOptions) {
199+
options := cmdparser.CommandOptions{
200+
Use: "mycommand",
201+
Short: localizer.Sprintf("Description"),
202+
Run: c.run,
203+
}
204+
c.Cmd.DefineCommand(options)
205+
// Add flags
206+
}
207+
208+
func (c *MyCommand) run() {
209+
// Command logic
210+
}
211+
```
212+
213+
### Adding Features (Legacy CLI)
214+
215+
For new features related to querying SQL Server and displaying query results, add them to the legacy CLI:
216+
217+
1. Add new fields to the `SQLCmdArguments` struct in `cmd/sqlcmd/sqlcmd.go`
218+
2. Register new flags in the `setFlags` function
219+
3. Add validation logic in the `Validate` method if needed
220+
4. Update `setVars` or `setConnect` functions to use the new arguments
221+
5. Implement the feature logic in the `run` function or related functions
222+
6. Add corresponding tests in `cmd/sqlcmd/sqlcmd_test.go`
187223

188224
### Adding a New Configuration Option
189225

0 commit comments

Comments
 (0)