MCPcopy Create free account
hub / github.com/aptly-dev/aptly / aptlyRepoListJSON

Function aptlyRepoListJSON

cmd/repo_list.go:74–102  ·  view source on GitHub ↗
(_ *commander.Command, _ []string)

Source from the content-addressed store, hash-verified

72}
73
74func aptlyRepoListJSON(_ *commander.Command, _ []string) error {
75 var err error
76
77 repos := make([]*deb.LocalRepo, context.NewCollectionFactory().LocalRepoCollection().Len())
78 i := 0
79 _ = context.NewCollectionFactory().LocalRepoCollection().ForEach(func(repo *deb.LocalRepo) error {
80 e := context.NewCollectionFactory().LocalRepoCollection().LoadComplete(repo)
81 if e != nil {
82 return e
83 }
84
85 repos[i] = repo
86 i++
87 return nil
88 })
89
90 _ = context.CloseDatabase()
91
92 sort.Slice(repos, func(i, j int) bool {
93 return repos[i].Name < repos[j].Name
94 })
95 if output, e := json.MarshalIndent(repos, "", " "); e == nil {
96 fmt.Println(string(output))
97 } else {
98 err = e
99 }
100
101 return err
102}
103
104func makeCmdRepoList() *commander.Command {
105 cmd := &commander.Command{

Callers 1

aptlyRepoListFunction · 0.85

Calls 6

LocalRepoCollectionMethod · 0.80
NewCollectionFactoryMethod · 0.80
CloseDatabaseMethod · 0.80
LenMethod · 0.45
ForEachMethod · 0.45
LoadCompleteMethod · 0.45

Tested by

no test coverage detected