mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-01-12 03:21:33 +00:00
59 lines
1.2 KiB
Go
59 lines
1.2 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/gonuts/commander"
|
|
"github.com/gonuts/flag"
|
|
"github.com/smira/aptly/debian"
|
|
"sort"
|
|
)
|
|
|
|
func aptlyMirrorList(cmd *commander.Command, args []string) error {
|
|
var err error
|
|
if len(args) != 0 {
|
|
cmd.Usage()
|
|
return err
|
|
}
|
|
|
|
repoCollection := debian.NewRemoteRepoCollection(context.database)
|
|
|
|
if repoCollection.Len() > 0 {
|
|
fmt.Printf("List of mirrors:\n")
|
|
repos := make([]string, repoCollection.Len())
|
|
i := 0
|
|
repoCollection.ForEach(func(repo *debian.RemoteRepo) error {
|
|
repos[i] = repo.String()
|
|
i++
|
|
return nil
|
|
})
|
|
|
|
sort.Strings(repos)
|
|
for _, repo := range repos {
|
|
fmt.Printf(" * %s\n", repo)
|
|
}
|
|
|
|
fmt.Printf("\nTo get more information about mirror, run `aptly mirror show <name>`.\n")
|
|
} else {
|
|
fmt.Printf("No mirrors found, create one with `aptly mirror create ...`.\n")
|
|
}
|
|
return err
|
|
}
|
|
|
|
func makeCmdMirrorList() *commander.Command {
|
|
cmd := &commander.Command{
|
|
Run: aptlyMirrorList,
|
|
UsageLine: "list",
|
|
Short: "list mirrors",
|
|
Long: `
|
|
List shows full list of remote repository mirrors.
|
|
|
|
Example:
|
|
|
|
$ aptly mirror list
|
|
`,
|
|
Flag: *flag.NewFlagSet("aptly-mirror-list", flag.ExitOnError),
|
|
}
|
|
|
|
return cmd
|
|
}
|