From 656dddda538d03d5aa47c81f494c21f1a18e634b Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Tue, 21 Jan 2014 15:33:05 +0400 Subject: [PATCH] Sort mirrors when listing. --- cmd_mirror.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd_mirror.go b/cmd_mirror.go index 3b47f9fd..23d351e9 100644 --- a/cmd_mirror.go +++ b/cmd_mirror.go @@ -6,6 +6,7 @@ import ( "github.com/gonuts/flag" "github.com/smira/aptly/debian" "github.com/smira/aptly/utils" + "sort" "strings" ) @@ -20,12 +21,20 @@ func aptlyMirrorList(cmd *commander.Command, args []string) error { if repoCollection.Len() > 0 { fmt.Printf("List of mirrors:\n") + repos := make(sort.StringSlice, repoCollection.Len()) + i := 0 repoCollection.ForEach(func(repo *debian.RemoteRepo) error { - fmt.Printf(" * %s\n", repo) + repos[i] = repo.String() + i++ return nil }) - fmt.Printf("\nTo get more information about repository, run `aptly mirror show `.\n") + sort.Strings(repos) + for _, repo := range repos { + fmt.Printf(" * %s\n", repo) + } + + fmt.Printf("\nTo get more information about mirror, run `aptly mirror show `.\n") } else { fmt.Printf("No mirrors found, create one with `aptly mirror create ...`.\n") }