mirror of
https://github.com/vbatts/go-mtree.git
synced 2025-07-01 05:28:30 +00:00
*: make Keyword and KeyVal pervasive
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
5d26726bb1
commit
4eec68be4b
18 changed files with 434 additions and 367 deletions
19
entry.go
19
entry.go
|
@ -21,7 +21,7 @@ type Entry struct {
|
|||
Pos int // order in the spec
|
||||
Raw string // file or directory name
|
||||
Name string // file or directory name
|
||||
Keywords []string // TODO(vbatts) maybe a keyword typed set of values?
|
||||
Keywords []KeyVal // TODO(vbatts) maybe a keyword typed set of values?
|
||||
Type EntryType
|
||||
}
|
||||
|
||||
|
@ -94,23 +94,20 @@ func (e Entry) String() string {
|
|||
if e.Type == DotDotType {
|
||||
return e.Name
|
||||
}
|
||||
if e.Type == SpecialType || e.Type == FullType || inSlice("type=dir", e.Keywords) {
|
||||
return fmt.Sprintf("%s %s", e.Name, strings.Join(e.Keywords, " "))
|
||||
if e.Type == SpecialType || e.Type == FullType || inKeyValSlice("type=dir", e.Keywords) {
|
||||
return fmt.Sprintf("%s %s", e.Name, strings.Join(KeyValToString(e.Keywords), " "))
|
||||
}
|
||||
return fmt.Sprintf(" %s %s", e.Name, strings.Join(e.Keywords, " "))
|
||||
return fmt.Sprintf(" %s %s", e.Name, strings.Join(KeyValToString(e.Keywords), " "))
|
||||
}
|
||||
|
||||
// AllKeys returns the full set of KeyVals for the given entry, based on the
|
||||
// AllKeys returns the full set of KeyVal for the given entry, based on the
|
||||
// /set keys as well as the entry-local keys. Entry-local keys always take
|
||||
// precedence.
|
||||
func (e Entry) AllKeys() KeyVals {
|
||||
var kv KeyVals
|
||||
func (e Entry) AllKeys() []KeyVal {
|
||||
if e.Set != nil {
|
||||
kv = MergeSet(e.Set.Keywords, e.Keywords)
|
||||
} else {
|
||||
kv = NewKeyVals(e.Keywords)
|
||||
return MergeKeyValSet(e.Set.Keywords, e.Keywords)
|
||||
}
|
||||
return kv
|
||||
return e.Keywords
|
||||
}
|
||||
|
||||
// EntryType are the formats of lines in an mtree spec file
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue