Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Action = Parser.add(&Primary{ Description: "Returns true if the entry supports action", name: "action", args: "action", parseFunc: func(tokens []string) (types.EntryPredicate, []string, error) { if len(tokens) == 0 { return nil, nil, fmt.Errorf("requires additional arguments") } validActions := plugin.Actions() action, ok := validActions[tokens[0]] if !ok { validActionsArray := make([]string, 0, len(validActions)) for actionName := range validActions { validActionsArray = append(validActionsArray, actionName) } validActionsStr := strings.Join(validActionsArray, ", ") return nil, nil, fmt.Errorf("%v is an invalid action. Valid actions are %v", tokens[0], validActionsStr) } p := types.ToEntryP(func(e types.Entry) bool { return e.Supports(action) }) p.SetSchemaP(types.ToEntrySchemaP(func(s *types.EntrySchema) bool { for _, a := range s.Actions() { if action.Name == a { return true } } return false })) return p, tokens[1:], nil }, })
Action is the action primary
actionPrimary => <action> nolint
var Atime = newTimeAttrPrimary("atime")
Atime is the atime primary
nolint
var Crtime = newTimeAttrPrimary("crtime")
Crtime is the crtime primary
nolint
var Ctime = newTimeAttrPrimary("ctime")
Ctime is the ctime primary
nolint
var False = newBooleanPrimary(false)
False is the false primary
falsePrimary => -false nolint
var Kind = Parser.add(&Primary{ Description: "Returns true if the entry's kind matches pattern", DetailedDescription: kindDetailedDescription, name: "kind", args: "pattern", shortName: "k", parseFunc: func(tokens []string) (types.EntryPredicate, []string, error) { if len(tokens) == 0 { return nil, nil, fmt.Errorf("requires additional arguments") } g, err := glob.Compile(tokens[0]) if err != nil { return nil, nil, fmt.Errorf("invalid pattern: %v", err) } return kindP(g, false), tokens[1:], nil }, })
Kind is the kind primary
kindPrimary => -kind ShellPattern nolint
var Meta = Parser.add(&Primary{ Description: "Returns true if the entry's metadata satisfies the expression", DetailedDescription: metaDetailedDescription, name: "meta", args: "<expression>", shortName: "m", parseFunc: meta.Parse, })
Meta is the meta primary
metaPrimary => (-meta|-m) Expression
Expression => EmptyPredicate | KeySequence PredicateExpression EmptyPredicate => -empty
KeySequence => '.' Key Tail Key => [ ^.[ ] ]+ (i.e. one or more cs that aren't ".", "[", or "]") Tail => '.' Key Tail |
‘[' ? ‘]’ Tail | '[' * ']' Tail | '[' N ']' Tail | ""
PredicateExpression => (See the comments of expression.Parser#Parse)
Predicate => ObjectPredicate |
ArrayPredicate | PrimitivePredicate
ObjectPredicate => EmptyPredicate | ‘.’ Key OAPredicate
ArrayPredicate => EmptyPredicate |
‘[' ? ‘]’ OAPredicate | ‘[' * ‘]’ OAPredicate | ‘[' N ‘]’ OAPredicate |
OAPredicate => Predicate | "(" PredicateExpression ")"
PrimitivePredicate => NullPredicate |
ExistsPredicate | BooleanPredicate | NumericPredicate | TimePredicate | StringPredicate
NullPredicate => -null ExistsPredicate => -exists BooleanPredicate => -true | -false
NumericPredicate => (+|-)? Number Number => N | '{' N '}' | numeric.SizeRegex
TimePredicate => (+|-)? Duration Duration => numeric.DurationRegex | '{' numeric.DurationRegex '}'
StringPredicate => [^-].*
N => \d+ (i.e. some number > 0)
nolint
var Mtime = newTimeAttrPrimary("mtime")
Mtime is the mtime primary
nolint
var Name = Parser.add(&Primary{ Description: "Returns true if the entry's cname matches pattern", name: "name", args: "pattern", parseFunc: func(tokens []string) (types.EntryPredicate, []string, error) { if len(tokens) == 0 { return nil, nil, fmt.Errorf("requires additional arguments") } g, err := glob.Compile(tokens[0]) if err != nil { return nil, nil, fmt.Errorf("invalid pattern: %v", err) } return types.ToEntryP(func(e types.Entry) bool { return g.Match(e.CName) }), tokens[1:], nil }, })
Name is the name primary
namePrimary => -name ShellPattern nolint
var Parser = &parser{ primaryMap: make(map[string]*Primary), SetPrimaries: make(map[*Primary]bool), }
Parser parses `wash find` primaries.
var Path = Parser.add(&Primary{ Description: "Returns true if the entry's normalized path matches pattern", name: "path", args: "pattern", parseFunc: func(tokens []string) (types.EntryPredicate, []string, error) { if len(tokens) == 0 { return nil, nil, fmt.Errorf("requires additional arguments") } g, err := glob.Compile(tokens[0]) if err != nil { return nil, nil, fmt.Errorf("invalid pattern: %v", err) } return types.ToEntryP(func(e types.Entry) bool { return g.Match(e.NormalizedPath) }), tokens[1:], nil }, })
Path is the path primary
pathPrimary => -path ShellPattern nolint
var Size = Parser.add(&Primary{ Description: "Returns true if the entry's size attribute satisfies the given size predicate", DetailedDescription: sizeDetailedDescription, name: "size", args: "[+|-]n[ckMGTP]", parseFunc: func(tokens []string) (types.EntryPredicate, []string, error) { if len(tokens) == 0 { return nil, nil, fmt.Errorf("requires additional arguments") } numericP, parserID, err := numeric.ParsePredicate( tokens[0], numeric.ParsePositiveInt, numeric.ParseSize, ) if err != nil { return nil, nil, fmt.Errorf("%v: illegal size value", tokens[0]) } p := types.ToEntryP(func(e types.Entry) bool { if !e.Attributes.HasSize() { return false } size := int64(e.Attributes.Size()) if parserID == 0 { size = int64(math.Ceil(float64(size) / 512.0)) } return numericP(size) }) return p, tokens[1:], nil }, })
Size is the size primary
sizePrimary => -size (+|-)?(\d+ | numeric.SizeRegex)
nolint
var True = newBooleanPrimary(true)
True is the true primary
truePrimary => -true nolint