MCPcopy Index your code
hub / github.com/aptly-dev/aptly / PrintPackageList

Function PrintPackageList

cmd/cmd.go:41–66  ·  view source on GitHub ↗

PrintPackageList shows package list with specified format or default representation

(result *deb.PackageList, format, prefix string)

Source from the content-addressed store, hash-verified

39
40// PrintPackageList shows package list with specified format or default representation
41func PrintPackageList(result *deb.PackageList, format, prefix string) error {
42 result.PrepareIndex()
43
44 if format == "" {
45 return result.ForEachIndexed(func(p *deb.Package) error {
46 context.Progress().Printf(prefix+"%s\n", p)
47 return nil
48 })
49 }
50
51 formatTemplate, err := template.New("format").Parse(format)
52 if err != nil {
53 return fmt.Errorf("error parsing -format template: %s", err)
54 }
55
56 return result.ForEachIndexed(func(p *deb.Package) error {
57 b := &bytes.Buffer{}
58 err = formatTemplate.Execute(b, p.ExtendedStanza())
59 if err != nil {
60 return fmt.Errorf("error applying template: %s", err)
61 }
62 context.Progress().Printf(prefix+"%s\n", b.String())
63 return nil
64 })
65
66}
67
68// LookupOption checks boolean flag with default (usually config) and command-line
69// setting

Callers 3

ListPackagesRefListFunction · 0.85
aptlyPackageSearchFunction · 0.85

Calls 6

PrepareIndexMethod · 0.80
ForEachIndexedMethod · 0.80
ProgressMethod · 0.80
ExtendedStanzaMethod · 0.80
PrintfMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected