Skip to content

ℹ️ About

Display a brief description of Composer itself and parse the output into structured key-value pairs.

composer about outputs single-line information about Composer's name, version, description, etc. Composer Skills provides two methods: About returns the raw text, and ParseAboutOutput parses it into map[string]string.

When to Use

  • 🩺 Print a one-line Composer self-introduction during startup self-check.
  • 📊 Display Composer metadata (version, description) on a dashboard.
  • 🔍 Programmatically extract the Composer version number for version comparison (you can also use the more specialized GetVersionInfo).
  • 📝 Include Composer's about information when generating environment reports.

Method Signatures

MethodSignatureDescription
ℹ️ Aboutfunc (c *Composer) About() (string, error)Raw text from composer about
🔧 ParseAboutOutputfunc ParseAboutOutput(output string) map[string]stringParse into key-value map

Examples

go
package main

import (
	"fmt"
	"log"

	"github.com/scagogogo/composer-skills/pkg/composer"
)

func main() {
	comp, err := composer.New(composer.DefaultOptions())
	if err != nil {
		log.Fatal(err)
	}
	out, err := comp.About()
	if err != nil {
		log.Fatalf("Failed to get about: %v", err)
	}
	fmt.Println(out)
}

Structured Parsing

go
out, _ := comp.About()
info := composer.ParseAboutOutput(out)
for k, v := range info {
	fmt.Printf("%s: %s\n", k, v)
}
// Typical output:
// Composer: Composer
// version: 2.6.6
// ...

Using the Parse Function Independently

go
// You can pass any about-style text to parse
raw := "Composer: Composer\nversion: 2.6.6\nreleased: 2024-02-22"
info := composer.ParseAboutOutput(raw)
fmt.Println("version =", info["version"])

Advanced

Parsing Rules for ParseAboutOutput

Each line is split by : into key / value, with whitespace trimmed from both ends. Lines without a colon are skipped. Therefore, it only works for output in Key: Value format.

Want More Precise Version Information

About returns human-readable text. If you need structured major/minor/patch numbers and release date, use GetVersionInfo, which parses composer --version output into a VersionInfo struct.

Released under the MIT License