Merge pull request #134 from runcom/sort-flags

cmd/server: sort flags
This commit is contained in:
Mrunal Patel 2016-10-13 09:00:39 -07:00 committed by GitHub
commit 0b45bfcb36

View file

@ -4,6 +4,7 @@ import (
"fmt"
"net"
"os"
"sort"
"github.com/Sirupsen/logrus"
"github.com/kubernetes-incubator/cri-o/server"
@ -58,6 +59,18 @@ func mergeConfig(config *server.Config, ctx *cli.Context) error {
return nil
}
type byName []cli.Flag
func (f byName) Len() int {
return len(f)
}
func (f byName) Less(i, j int) bool {
return f[i].GetName() < f[j].GetName()
}
func (f byName) Swap(i, j int) {
f[i], f[j] = f[j], f[i]
}
func main() {
app := cli.NewApp()
app.Name = "ocid"
@ -121,6 +134,10 @@ func main() {
},
}
// remove once https://github.com/urfave/cli/pull/544 lands
sort.Sort(byName(app.Flags))
sort.Sort(byName(configCommand.Flags))
app.Commands = []cli.Command{
configCommand,
}