mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-08 22:30:41 +00:00
Sort snapshots when listing.
This commit is contained in:
+12
-1
@@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/gonuts/flag"
|
"github.com/gonuts/flag"
|
||||||
"github.com/smira/aptly/debian"
|
"github.com/smira/aptly/debian"
|
||||||
"github.com/wsxiaoys/terminal/color"
|
"github.com/wsxiaoys/terminal/color"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -58,11 +59,21 @@ func aptlySnapshotList(cmd *commander.Command, args []string) error {
|
|||||||
|
|
||||||
if snapshotCollection.Len() > 0 {
|
if snapshotCollection.Len() > 0 {
|
||||||
fmt.Printf("List of snapshots:\n")
|
fmt.Printf("List of snapshots:\n")
|
||||||
|
|
||||||
|
snapshots := make(sort.StringSlice, snapshotCollection.Len())
|
||||||
|
|
||||||
|
i := 0
|
||||||
snapshotCollection.ForEach(func(snapshot *debian.Snapshot) error {
|
snapshotCollection.ForEach(func(snapshot *debian.Snapshot) error {
|
||||||
fmt.Printf(" * %s\n", snapshot)
|
snapshots[i] = snapshot.String()
|
||||||
|
i++
|
||||||
return nil
|
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 <name>`.\n")
|
fmt.Printf("\nTo get more information about snapshot, run `aptly snapshot show <name>`.\n")
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("\nNo snapshots found, create one with `aptly snapshot create...`.\n")
|
fmt.Printf("\nNo snapshots found, create one with `aptly snapshot create...`.\n")
|
||||||
|
|||||||
Reference in New Issue
Block a user