mirror of
https://github.com/spf13/cobra
synced 2024-11-24 22:57:12 +00:00
Merge pull request #92 from eparis/sort-valid-args
Sort the valid args before output
This commit is contained in:
commit
9cb5e85029
1 changed files with 2 additions and 0 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
|
@ -282,6 +283,7 @@ func writeRequiredFlag(cmd *Command, out *bytes.Buffer) {
|
||||||
|
|
||||||
func writeRequiredNoun(cmd *Command, out *bytes.Buffer) {
|
func writeRequiredNoun(cmd *Command, out *bytes.Buffer) {
|
||||||
fmt.Fprintf(out, " must_have_one_noun=()\n")
|
fmt.Fprintf(out, " must_have_one_noun=()\n")
|
||||||
|
sort.Sort(sort.StringSlice(cmd.ValidArgs))
|
||||||
for _, value := range cmd.ValidArgs {
|
for _, value := range cmd.ValidArgs {
|
||||||
fmt.Fprintf(out, " must_have_one_noun+=(%q)\n", value)
|
fmt.Fprintf(out, " must_have_one_noun+=(%q)\n", value)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue