Skip to content
This repository has been archived by the owner on Jun 22, 2021. It is now read-only.

Add support for dynamically matching targets #37

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

SevereOverfl0w
Copy link
Contributor

There is a basis protocol (Target) which exposes match? for whether or
not a target matches. A sequential search is then performed over all
targets for each input target.

Example usage of this feature:

;; Machfile.edn
{#mach/glob "*.md" {product "somefile"
		    produce (str "# A title")}}

$ mach hello.md
Writing somefile

Further functionality that is necessary to make this feature useful is
the exposure of the match ctx (already assoced onto the target when it
matches) so that code can refer to the full path. To extend the example
above, the future feature should allow the product to be set based on
the matching input.

I haven't thoroughly tested this, so a second pair of eyes over this
would be good.

There is a basis protocol (Target) which exposes match? for whether or
not a target matches. A sequential search is then performed over all
targets for each input target.

Example usage of this feature:

```
;; Machfile.edn
{#mach/glob "*.md" {product "somefile"
		    produce (str "# A title")}}

$ mach hello.md
Writing somefile
```

Further functionality that is necessary to make this feature useful is
the exposure of the match ctx (already assoced onto the target when it
matches) so that code can refer to the full path. To extend the example
above, the future feature should allow the product to be set based on
the matching input.

I haven't thoroughly tested this, so a second pair of eyes over this
would be good.
This binds 2 vars during the evaluation of targets.

`mach.core/*target-ctx*` this is bound to a string that contains the
whole string that matched this target e.g. a glob fo* would match
"foo.xml", this var would contain "foo.xml"

`mach.core/*matcher-ctx*` this is bound to the object that was used to
match this target.  e.g. for `#mach/glob "fo*"` the underlying Glob
object will be bound to this var.
@SevereOverfl0w
Copy link
Contributor Author

new commit added which dynamically binds vars relative to the match context.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant