Skip to content

Commit

Permalink
sort output of -lists
Browse files Browse the repository at this point in the history
  • Loading branch information
mgumz committed Sep 25, 2016
1 parent 46c44b0 commit 349d5c4
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"io"
"os"
"sort"
"strings"
)

Expand All @@ -21,7 +22,7 @@ func main() {
flag.PrintDefaults()
}

list := flag.String("list", "diceware", "name of list to use")
list := flag.String("list", "diceware", "name of list to use, see -lists")
listLists := flag.Bool("lists", false, "list internal lists")
dumpList := flag.Bool("dump", false, "dump the content of a -list")
rolls := flag.Int("rolls", 6, "number of rolls for -electronic")
Expand All @@ -34,7 +35,7 @@ func main() {
flag.Parse()

if *listLists {
for name, _ := range internalLists {
for _, name := range internalListNames() {
fmt.Println(name)
}
return
Expand Down Expand Up @@ -113,3 +114,14 @@ func listReaderFromString(list string) io.ReadCloser {
}
return gz
}

func internalListNames() []string {
names := make([]string, len(internalLists))
i := 0
for name, _ := range internalLists {
names[i] = name
i += 1
}
sort.Strings(names)
return names
}

0 comments on commit 349d5c4

Please sign in to comment.