diff --git a/cmd_snapshot.go b/cmd_snapshot.go index fd4fac64..6f151b4e 100644 --- a/cmd_snapshot.go +++ b/cmd_snapshot.go @@ -6,6 +6,7 @@ import ( "github.com/gonuts/flag" "github.com/smira/aptly/debian" "github.com/wsxiaoys/terminal/color" + "sort" "strings" ) @@ -58,11 +59,21 @@ func aptlySnapshotList(cmd *commander.Command, args []string) error { if snapshotCollection.Len() > 0 { fmt.Printf("List of snapshots:\n") + + snapshots := make(sort.StringSlice, snapshotCollection.Len()) + + i := 0 snapshotCollection.ForEach(func(snapshot *debian.Snapshot) error { - fmt.Printf(" * %s\n", snapshot) + snapshots[i] = snapshot.String() + i++ return nil }) + sort.Strings(snapshots) + for _, snapshot := range snapshots { + fmt.Printf(" * %s\n", snapshot) + } + fmt.Printf("\nTo get more information about snapshot, run `aptly snapshot show `.\n") } else { fmt.Printf("\nNo snapshots found, create one with `aptly snapshot create...`.\n")