Skip to content

📈 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

ParameterTypeDescription
NoneThis method takes no parameters

Return value

  • *StatusResult: status check result
  • error: 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 status internally, then parses the result via ParseStatusOutput
  • Parsing logic: if the output is empty, Modified=false; otherwise, each non-empty line is added to Files and Modified is set to true
  • For the raw text version, see Status

Released under the MIT License