From 62f8e2b5ad2fd575f0dbacbf267c480a4d687997 Mon Sep 17 00:00:00 2001 From: Derek Parker Date: Fri, 20 May 2016 10:33:08 -0700 Subject: [PATCH] terminal: Display commands in alphabetical order --- terminal/command.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/terminal/command.go b/terminal/command.go index 7c8a75c3..cc4ffc6a 100644 --- a/terminal/command.go +++ b/terminal/command.go @@ -67,6 +67,12 @@ var ( ShortLoadConfig = api.LoadConfig{false, 0, 64, 0, 3} ) +type ByFirstAlias []command + +func (a ByFirstAlias) Len() int { return len(a) } +func (a ByFirstAlias) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a ByFirstAlias) Less(i, j int) bool { return a[i].aliases[0] < a[j].aliases[0] } + // DebugCommands returns a Commands struct with default commands defined. func DebugCommands(client service.Client) *Commands { c := &Commands{client: client} @@ -207,6 +213,7 @@ Supported commands: print, stack and goroutine)`}, Specifies that the breakpoint or tracepoint should break only if the boolean expression is true.`}, } + sort.Sort(ByFirstAlias(c.cmds)) return c }