From 0fc734c3c57c3040ad918745d62b0bdfa5a27bf1 Mon Sep 17 00:00:00 2001 From: Eric Paris Date: Mon, 13 Apr 2015 18:44:05 -0400 Subject: [PATCH] Sort the valid args before output We do this so we get stable repeatable output and can see if updates are necessary or if it is just golang doing the same thing twice differently --- bash_completions.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bash_completions.go b/bash_completions.go index 1c56407..dee95b3 100644 --- a/bash_completions.go +++ b/bash_completions.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" "os" + "sort" "strings" "github.com/spf13/pflag" @@ -282,6 +283,7 @@ func writeRequiredFlag(cmd *Command, out *bytes.Buffer) { func writeRequiredNoun(cmd *Command, out *bytes.Buffer) { fmt.Fprintf(out, " must_have_one_noun=()\n") + sort.Sort(sort.StringSlice(cmd.ValidArgs)) for _, value := range cmd.ValidArgs { fmt.Fprintf(out, " must_have_one_noun+=(%q)\n", value) }