aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd/mbf
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/mbf')
-rw-r--r--cmd/mbf/info.go34
1 files changed, 24 insertions, 10 deletions
diff --git a/cmd/mbf/info.go b/cmd/mbf/info.go
index d8691f60..5e3450f3 100644
--- a/cmd/mbf/info.go
+++ b/cmd/mbf/info.go
@@ -20,6 +20,12 @@ func commandInfo(
writeStatus bool,
r *rosa.Report,
) (err error) {
+ if writeStatus && cm.c == nil {
+ if err = cm.open(); err != nil {
+ return
+ }
+ }
+
if len(args) == 0 {
for _, h := range rosa.CollectAll() {
fmt.Println(h)
@@ -27,6 +33,15 @@ func commandInfo(
return nil
}
+ const (
+ namePrefix = "name : "
+ descPrefix = "description : "
+ sitePrefix = "website : "
+ statPrefix = "status : "
+ sizePrefix = "size :"
+ loadPrefix = "depends on :"
+ )
+
// recovered by HandleAccess
mustPrintln := func(a ...any) {
if _, _err := fmt.Fprintln(w, a...); _err != nil {
@@ -49,15 +64,15 @@ func commandInfo(
if meta.Version != rosa.Unversioned {
suffix += "-" + meta.Version
}
- mustPrintln("name : " + name + suffix)
+ mustPrintln(namePrefix + name + suffix)
- mustPrintln("description : " + meta.Description)
+ mustPrintln(descPrefix + meta.Description)
if meta.Website != "" {
- mustPrintln("website : " +
+ mustPrintln(sitePrefix +
strings.TrimSuffix(meta.Website, "/"))
}
if len(meta.Runtimes) > 0 {
- mustPrint("depends on :")
+ mustPrint(loadPrefix)
for _, d := range meta.Runtimes {
_meta, _ := rosa.MustLoad(d)
s := _meta.Name
@@ -69,7 +84,6 @@ func commandInfo(
mustPrintln()
}
- const statusPrefix = "status : "
if writeStatus {
if r == nil {
var f io.ReadSeekCloser
@@ -80,13 +94,13 @@ func commandInfo(
if err != nil {
if errors.Is(err, os.ErrNotExist) {
mustPrintln(
- statusPrefix + "not yet cured",
+ statPrefix + "not yet cured",
)
} else {
return
}
} else {
- mustPrint(statusPrefix)
+ mustPrint(statPrefix)
_, err = io.Copy(w, f)
if err = errors.Join(err, f.Close()); err != nil {
return
@@ -96,11 +110,11 @@ func commandInfo(
status, n := r.ArtifactOf(cache.Ident(a))
if status == nil {
mustPrintln(
- statusPrefix + "not in report",
+ statPrefix + "not in report",
)
} else {
- mustPrintln("size :", n)
- mustPrint(statusPrefix)
+ mustPrintln(sizePrefix, n)
+ mustPrint(statPrefix)
if _, err = w.Write(status); err != nil {
return
}