Comments (1)
These are all great questions and should be clarified in the docs.
I would expect that the pattern /{a,}/**/x.txt would require matched files to be at least two directories deep since / is the root, {a,}/ is one deep and then **/ is another one or more.
So you're thinking that /a/x.txt
and /d/x.txt
should not be matches for /{a,}/**/x.txt
? I actually wrote a new test to confirm the docs:
[Test]
public void WildcardShouldMatchEmptyPath()
{
// Given
TestFileProvider fileProvider = new TestFileProvider();
fileProvider.AddDirectory("/");
fileProvider.AddDirectory("/root");
fileProvider.AddDirectory("/root/a");
fileProvider.AddDirectory("/root/a/b");
fileProvider.AddDirectory("/root/d");
fileProvider.AddFile("/root/a/x.txt");
fileProvider.AddFile("/root/a/b/x.txt");
fileProvider.AddFile("/root/d/x.txt");
IDirectory directory = fileProvider.GetDirectory("/");
// When
IEnumerable<IFile> matches = Globber.GetFiles(directory, "root/{a,}/**/x.txt");
// Then
matches.Select(x => x.Path.FullPath).ShouldBe(
new[] { "/root/a/x.txt", "/root/a/b/x.txt", "/root/d/x.txt" }, true);
}
Sure enough, the **/
pattern matches zero or more path segments. I'll try to clarify this in the docs.
There is one thing wrong with the example though: rooted globbing patterns aren't allowed. So the pattern /{a,}/**/x.txt
from the docs would actually throw an exception - I'll need to get that corrected.
It says that * and ** match any number of characters, does that mean 0 or more such that /*.txt would match "/.txt"?
That's correct, *.txt
would match a file named .txt
Is {n,x} an or statement that will match either "n" or "x" or is this a range that will match anything from "n" to "x", such as "t"?
The former - it specifies a set, not a range.
If {n,x} is an or statement then can it be even longer, such as {n,x,y} to match three characters?
Correct.
When you leave one side null, for example {c,}, does it match everything that is "c" or greater meaning that it would match "c" and "t", but not "a" or "b"
No, there's no range calculus going on. It's most useful when dealing with "not" logic like {!a,}
which means "any match except a".
It says that ! is useful when used with multiple expansion such as {*,!x}. Is it usable in any other way and what would it mean in that context?
The best way to get an idea how !
works is to probably look at the test cases here: https://github.com/Wyamio/Wyam/blob/15c34df68f3908019b4ff289e82ffdc346b15ca9/tests/core/Wyam.Core.Tests/IO/Globbing/GlobberFixture.cs#L126-L162 One interesting use is to exclude specific extensions: {!.txt,}
Thanks a lot for these great questions - it challenged some of my own recollection of how the globbing works and made me write a few new unit tests just to be sure I understood it correctly. I'll revisit the docs around this area soon (and will keep this issue open as a reminder until I do).
from wyam.web.
Related Issues (20)
- Bad markdown code syntax HOT 2
- Can't get CSS to render locally HOT 4
- GitHub URL is case sensitive HOT 3
- Better document relationship between input, output, and root paths
- Add KB article on module input/output behavior and multiplicity
- Add KB article on tools package
- 404 https://wyam.io/modules/searchindex HOT 3
- the build is red HOT 2
- Incorrect command line example for using the Solid State blog theme HOT 1
- Explain extensionless behavior in getting started HOT 1
- Make text links more visible HOT 1
- Recipe docs have copy/paste typos
- Details how to set Keys from the CLI would be helpful HOT 1
- Showroom in wyam.io HOT 2
- Add Chocolatey to installation. HOT 1
- Mardown table not well rendered
- Website errors HOT 4
- Improv hero link
- AutoLinkTypes docs theme setting is slightly confusing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wyam.web.