📋 ParseStatusOutput
Parses the text output of composer status to determine whether installed dependencies have local modifications, and returns *StatusResult.
When to use
Use this when you already have the output of composer status and need to programmatically detect whether dependency files in the vendor directory have been locally modified. Empty output means no modifications; any non-empty line indicates a modified file. It is the parser called internally by StatusStructured.
Signature
go
func ParseStatusOutput(output string) *StatusResultParameters
| Parameter | Type | Description |
|---|---|---|
output | string | The raw output of composer status |
Return value
*StatusResult: the status result, containingModified(bool,truewhenever the output is non-empty),Files([]string, the list of modified files), andOutput(the raw output).
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)
}
output, err := comp.Run("status")
if err != nil {
log.Fatal(err)
}
result := composer.ParseStatusOutput(output)
if result.Modified {
fmt.Printf("Found %d locally modified files:\n", len(result.Files))
for _, f := range result.Files {
fmt.Println(" -", f)
}
} else {
fmt.Println("No local modifications")
}
}Advanced
- 🔍 Parsing logic: after
TrimSpace, if empty →Modified=false; otherwise split by\n, add each non-empty line toFiles, and setModified=true. - 🚀 To execute the command and parse in one step, use
StatusStructured(); to run with options, useStatusWithOptions(options). - 🔗 For related diagnostic parsers, see
ParseDiagnoseOutputandParseCheckOutput.