mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-07-27 13:57:46 +00:00
Command aptly repo list.
This commit is contained in:
@@ -12,6 +12,7 @@ func makeCmdRepo() *commander.Command {
|
|||||||
Subcommands: []*commander.Command{
|
Subcommands: []*commander.Command{
|
||||||
makeCmdRepoCreate(),
|
makeCmdRepoCreate(),
|
||||||
makeCmdRepoShow(),
|
makeCmdRepoShow(),
|
||||||
|
makeCmdRepoList(),
|
||||||
},
|
},
|
||||||
Flag: *flag.NewFlagSet("aptly-repo", flag.ExitOnError),
|
Flag: *flag.NewFlagSet("aptly-repo", flag.ExitOnError),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/gonuts/commander"
|
||||||
|
"github.com/gonuts/flag"
|
||||||
|
"github.com/smira/aptly/debian"
|
||||||
|
"sort"
|
||||||
|
)
|
||||||
|
|
||||||
|
func aptlyRepoList(cmd *commander.Command, args []string) error {
|
||||||
|
var err error
|
||||||
|
if len(args) != 0 {
|
||||||
|
cmd.Usage()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
localRepoCollection := debian.NewLocalRepoCollection(context.database)
|
||||||
|
|
||||||
|
if localRepoCollection.Len() > 0 {
|
||||||
|
fmt.Printf("List of mirrors:\n")
|
||||||
|
repos := make([]string, localRepoCollection.Len())
|
||||||
|
i := 0
|
||||||
|
localRepoCollection.ForEach(func(repo *debian.LocalRepo) error {
|
||||||
|
err := localRepoCollection.LoadComplete(repo)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
repos[i] = fmt.Sprintf(" * %s (packages: %d)", repo.String(), repo.NumPackages())
|
||||||
|
i++
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
sort.Strings(repos)
|
||||||
|
for _, repo := range repos {
|
||||||
|
fmt.Println(repo)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("\nTo get more information about local repository, run `aptly repo show <name>`.\n")
|
||||||
|
} else {
|
||||||
|
fmt.Printf("No local repositories found, create one with `aptly repo create ...`.\n")
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeCmdRepoList() *commander.Command {
|
||||||
|
cmd := &commander.Command{
|
||||||
|
Run: aptlyRepoList,
|
||||||
|
UsageLine: "list",
|
||||||
|
Short: "list local package repositories",
|
||||||
|
Long: `
|
||||||
|
List shows full list of local package repositories.
|
||||||
|
|
||||||
|
ex:
|
||||||
|
$ aptly repo list
|
||||||
|
`,
|
||||||
|
Flag: *flag.NewFlagSet("aptly-repo-list", flag.ExitOnError),
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
No local repositories found, create one with `aptly repo create ...`.
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
List of mirrors:
|
||||||
|
* [repo1] (packages: 0)
|
||||||
|
* [repo2]: Cool2 (packages: 0)
|
||||||
|
* [repo3]: Cool3 (packages: 0)
|
||||||
|
|
||||||
|
To get more information about local repository, run `aptly repo show <name>`.
|
||||||
@@ -4,3 +4,4 @@ Testing local repo management
|
|||||||
|
|
||||||
from .create import *
|
from .create import *
|
||||||
from .show import *
|
from .show import *
|
||||||
|
from .list import *
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
from lib import BaseTest
|
||||||
|
|
||||||
|
|
||||||
|
class ListRepo1Test(BaseTest):
|
||||||
|
"""
|
||||||
|
list local repos: no repos
|
||||||
|
"""
|
||||||
|
runCmd = "aptly repo list"
|
||||||
|
|
||||||
|
|
||||||
|
class ListRepo2Test(BaseTest):
|
||||||
|
"""
|
||||||
|
list local repo: normal
|
||||||
|
"""
|
||||||
|
fixtureCmds = [
|
||||||
|
"aptly repo create -comment=Cool3 repo3",
|
||||||
|
"aptly repo create -comment=Cool2 repo2",
|
||||||
|
"aptly repo create repo1",
|
||||||
|
]
|
||||||
|
runCmd = "aptly repo list"
|
||||||
Reference in New Issue
Block a user