Add sorting for the future commands.
authorOllivier Robert <roberto@keltia.net>
Mon, 10 Apr 2017 17:11:47 +0200
changeset 41 79be65ec4afd
parent 40 c2caa5241c4a
child 42 2bebcae94ce1
Add sorting for the future commands.
cmd/gondole/utils.go
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmd/gondole/utils.go	Mon Apr 10 17:11:47 2017 +0200
@@ -0,0 +1,11 @@
+package main
+
+import "github.com/urfave/cli"
+
+// ByAlphabet is for sorting
+type ByAlphabet []cli.Command
+
+func (a ByAlphabet) Len() int           { return len(a) }
+func (a ByAlphabet) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
+func (a ByAlphabet) Less(i, j int) bool { return a[i].Name < a[j].Name }
+