📈 StatusStructured
Checks whether installed dependencies have local modifications and returns structured results (whether modified, list of modified files).
When to use
Use this in CI when you need to determine whether dependencies have been altered as a boolean value or file list, rather than parsing plain-text output.
Signature
go
func (c *Composer) StatusStructured() (*StatusResult, error)Parameters
| Parameter | Type | Description |
|---|---|---|
| None | — | This method takes no parameters |
Return value
*StatusResult: status check resulterror: returned when the command fails to execute
go
type StatusResult struct {
Modified bool `json:"modified"`
Files []string `json:"files,omitempty"`
Output string `json:"output,omitempty"`
}Example
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)
}
result, err := comp.StatusStructured()
if err != nil {
log.Fatalf("check status failed: %v", err)
}
if result.Modified {
fmt.Printf("found %d modified files\n", len(result.Files))
for _, f := range result.Files {
fmt.Println("- " + f)
}
} else {
fmt.Println("dependencies not modified")
}
}Advanced
- This method calls
composer statusinternally, then parses the result viaParseStatusOutput - Parsing logic: if the output is empty,
Modified=false; otherwise, each non-empty line is added toFilesandModifiedis set totrue - For the raw text version, see Status