From 80f85b01d5bacc9d16408e7640b74f4698952217 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Wed, 29 Nov 2023 20:28:12 -0500 Subject: [PATCH] WIP --- cmd/gomtree/cmd/validate.go | 13 ++++++++++++- hierarchy.go | 7 +++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/cmd/gomtree/cmd/validate.go b/cmd/gomtree/cmd/validate.go index ed451b1..16719f1 100644 --- a/cmd/gomtree/cmd/validate.go +++ b/cmd/gomtree/cmd/validate.go @@ -24,6 +24,10 @@ func NewValidateCommand() *cli.Command { Aliases: []string{"c"}, Usage: "Create a directory hierarchy spec", }, + &cli.BoolFlag{ + Name: "C", + Usage: "Print ('dump') the specification provided by `-f` with full path names", + }, &cli.StringSliceFlag{ Name: "file", Aliases: []string{"f"}, @@ -78,7 +82,7 @@ func NewValidateCommand() *cli.Command { &cli.StringFlag{ Name: "result-format", Value: "bsd", - Usage: "output the validation results using the given format (bsd, json, path)", + Usage: "output the validation results/errors using the given format (bsd, json, path)", }, }, } @@ -245,6 +249,13 @@ func validateAction(c *cli.Context) error { excludes = append(excludes, mtree.ExcludeNonDirectories) } + if c.Bool("C") && specDh != nil { + specDh.Entries + + + return nil + } + // -u // Failing early here. Processing is done below. if c.Bool("update-attributes") && c.String("tar") != "" { diff --git a/hierarchy.go b/hierarchy.go index f004934..2eca4e8 100644 --- a/hierarchy.go +++ b/hierarchy.go @@ -5,12 +5,15 @@ import ( "sort" ) -// DirectoryHierarchy is the mapped structure for an mtree directory hierarchy -// spec +// DirectoryHierarchy is the mapped structure for an mtree directory hierarchy specification. type DirectoryHierarchy struct { Entries []Entry } +var DefaultDirectoryHierarchyFormatter +type DirectoryHierarchyFormatter interface {} + + // WriteTo simplifies the output of the resulting hierarchy spec. // Satisfies the `io.WriterTo` interface. func (dh DirectoryHierarchy) WriteTo(w io.Writer) (n int64, err error) {