From 1a01b95b6c86d07d4fe95640ae07718ed3be0652 Mon Sep 17 00:00:00 2001 From: Bob Matcuk Date: Sat, 2 May 2020 09:14:17 -0400 Subject: [PATCH] README adjustments --- README.md | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 466101c..074b77d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,12 @@ +# doublestar + +Path pattern matching and globbing supporting `doublestar` (`**`) patterns. + ![Release](https://img.shields.io/github/release/bmatcuk/doublestar.svg?branch=master) [![Build Status](https://travis-ci.org/bmatcuk/doublestar.svg?branch=master)](https://travis-ci.org/bmatcuk/doublestar) [![codecov.io](https://img.shields.io/codecov/c/github/bmatcuk/doublestar.svg?branch=master)](https://codecov.io/github/bmatcuk/doublestar?branch=master) -# doublestar +## About **doublestar** is a [golang](http://golang.org/) implementation of path pattern matching and globbing with support for "doublestar" (aka globstar: `**`) @@ -11,7 +15,7 @@ patterns. doublestar patterns match files and directories recursively. For example, if you had the following directory structure: -``` +```bash grandparent `-- parent |-- child1 @@ -43,9 +47,10 @@ To use it in your code, you must import it: import "github.com/bmatcuk/doublestar" ``` -## Functions +## Usage ### Match + ```go func Match(pattern, name string) (bool, error) ``` @@ -61,11 +66,12 @@ want to use `PathMatch()` (below) instead. ### PathMatch + ```go func PathMatch(pattern, name string) (bool, error) ``` -PathMatch returns true if `name` matches the file name `pattern` +PathMatch returns true if `name` matches the file name `pattern` ([see below](#patterns)). The difference between Match and PathMatch is that PathMatch will automatically use your system's path separator to split `name` and `pattern`. @@ -73,6 +79,7 @@ and `pattern`. `PathMatch()` is meant to be a drop-in replacement for `filepath.Match()`. ### Glob + ```go func Glob(pattern string) ([]string, error) ``` @@ -83,7 +90,7 @@ directory), or absolute. `Glob()` is meant to be a drop-in replacement for `filepath.Glob()`. -## Patterns +### Patterns **doublestar** supports the following special terms in the patterns: @@ -97,7 +104,7 @@ Special Terms | Meaning Any character with a special meaning can be escaped with a backslash (`\`). -### Character Classes +#### Character Classes Character classes support the following: @@ -107,7 +114,7 @@ Class | Meaning `[a-z]` | matches any single character in the range `[^class]` | matches any single character which does *not* match the class -## Abstracting the `os` package +### Abstracting the `os` package **doublestar** by default uses the `Open`, `Stat`, and `Lstat`, functions and `PathSeparator` value from the standard library's `os` package. To abstract @@ -118,12 +125,16 @@ operate on an `OS` interface: ```go type OS interface { - Lstat(name string) (os.FileInfo, error) - Open(name string) (*os.File, error) - PathSeparator() rune - Stat(name string) (os.FileInfo, error) + Lstat(name string) (os.FileInfo, error) + Open(name string) (*os.File, error) + PathSeparator() rune + Stat(name string) (os.FileInfo, error) } ``` `StandardOS` is a value that implements this interface by calling functions in -the standard library's `os` package. \ No newline at end of file +the standard library's `os` package. + +## License + +[MIT License](LICENSE)