mirror of
https://github.com/vbatts/go-mtree.git
synced 2024-12-22 05:46:30 +00:00
cmd: add --result-format=path format
This allows for shell callers to just get a simple diff of what files changed between the two invocations of go-mtree. This is somewhat similar to supplying -f twice to the BSD mtree (though that compares two specs and also gives you information about what *kind* of change occurred). Signed-off-by: Aleksa Sarai <asarai@suse.de>
This commit is contained in:
parent
692f56a830
commit
119cdc314c
1 changed files with 10 additions and 0 deletions
|
@ -32,6 +32,7 @@ var formats = map[string]func(*mtree.Result) string{
|
|||
return buffer.String()
|
||||
},
|
||||
|
||||
// Outputs the full result struct in JSON.
|
||||
"json": func(r *mtree.Result) string {
|
||||
var buffer bytes.Buffer
|
||||
if err := json.NewEncoder(&buffer).Encode(r); err != nil {
|
||||
|
@ -39,6 +40,15 @@ var formats = map[string]func(*mtree.Result) string{
|
|||
}
|
||||
return buffer.String()
|
||||
},
|
||||
|
||||
// Outputs only the paths which failed to validate.
|
||||
"path": func(r *mtree.Result) string {
|
||||
var buffer bytes.Buffer
|
||||
for _, fail := range r.Failures {
|
||||
fmt.Fprintln(&buffer, fail.Path)
|
||||
}
|
||||
return buffer.String()
|
||||
},
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
|
Loading…
Reference in a new issue