mirror of
https://github.com/go-delve/delve.git
synced 2025-10-27 20:23:41 +08:00
@ -41,6 +41,8 @@ type Commands struct {
|
||||
client service.Client
|
||||
}
|
||||
|
||||
var exitAliases = []string{"exit", "quit", "q"}
|
||||
|
||||
// Returns a Commands struct with default commands defined.
|
||||
func DebugCommands(client service.Client) *Commands {
|
||||
c := &Commands{client: client}
|
||||
@ -61,13 +63,22 @@ func DebugCommands(client service.Client) *Commands {
|
||||
{aliases: []string{"breakpoints", "bp"}, cmdFn: breakpoints, helpMsg: "Print out info for active breakpoints."},
|
||||
{aliases: []string{"print", "p"}, cmdFn: printVar, helpMsg: "Evaluate a variable."},
|
||||
{aliases: []string{"info"}, cmdFn: info, helpMsg: "Subcommands: args, funcs, locals, sources, vars, or regs."},
|
||||
{aliases: []string{"exit"}, cmdFn: nullCommand, helpMsg: "Exit the debugger."},
|
||||
{aliases: []string{"stack"}, cmdFn: stackCommand, helpMsg: "stack [<depth> [<goroutine id>]]. Prints stack."},
|
||||
{aliases: exitAliases, cmdFn: nullCommand, helpMsg: "Exit the debugger."},
|
||||
{aliases: []string{"stack", "bt"}, cmdFn: stackCommand, helpMsg: "stack [<depth> [<goroutine id>]]. Prints stack."},
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func isExitCommand(cmdstr string) bool {
|
||||
for _, a := range exitAliases {
|
||||
if a == cmdstr {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Register custom commands. Expects cf to be a func of type cmdfunc,
|
||||
// returning only an error.
|
||||
func (c *Commands) Register(cmdstr string, cf cmdfunc, helpMsg string) {
|
||||
|
||||
@ -84,7 +84,7 @@ func (t *Term) Run() (error, int) {
|
||||
}
|
||||
|
||||
cmdstr, args := parseCommand(cmdstr)
|
||||
if cmdstr == "exit" {
|
||||
if isExitCommand(cmdstr) {
|
||||
err, status = handleExit(t.client, t)
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user