Skip to content

Commit db67ea1

Browse files
committedAug 16, 2022
More docs
1 parent 25ab7ce commit db67ea1

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed
 

‎README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ It is built with only standard library dependencies. It additionally ships with
2020
- [match](#match)
2121
- [write](#write)
2222
- [Configuration](#configuration)
23+
- [Globbing](#globbing)
2324
- [Library](#library)
2425
- [SyntaxTree.read(filepath)](#syntaxtreereadfilepath)
2526
- [SyntaxTree.parse(source)](#syntaxtreeparsesource)
@@ -247,12 +248,20 @@ If this file is present, it will _always_ be used for CLI commands. You can also
247248

248249
### Globbing
249250

250-
When running commands with `stree` in the CLI, the globs must follow the Ruby-specific globbing syntax as specified in the docs for [Dir](https://ruby-doc.org/core-2.6.3/Dir.html#method-c-glob). To ensure consistent file matching across environments (e.g. CI vs. local development) it's safest to enclose the glob in quotes.
251+
When running commands with `stree`, it's common to pass in lists of files. For example:
251252

252-
For example, if you are in a Rails app and want to ignore the `db/schema.rb` file but check all other Ruby files and the `Gemfile`, you can use the following syntax:
253+
```sh
254+
stree write 'lib/*.rb' 'test/*.rb'
255+
```
256+
257+
The commands in the CLI accept any number of arguments. This means you _could_ pass `**/*.rb` (note the lack of quotes). This would make your shell expand out the file paths listed according to its own rules. (For example, [here](https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html) are the rules for GNU bash.)
258+
259+
However, it's recommended to instead use quotes, which means that Ruby is responsible for performing the file path expansion instead. This ensures a consistent experience across different environments and shells. The globs must follow the Ruby-specific globbing syntax as specified in the documentation for [Dir](https://ruby-doc.org/core-3.1.1/Dir.html#method-c-glob).
260+
261+
Baked into this syntax is the ability to provide exceptions to file name patterns as well. For example, if you are in a Rails app and want to exclude files named `schema.rb` but write all other Ruby files, you can use the following syntax:
253262

254263
```shell
255-
stree check '**/{[!schema]}*.rb' 'Gemfile'
264+
stree write '**/{[!schema]}*.rb'
256265
```
257266

258267
## Library

0 commit comments

Comments
 (0)
Please sign in to comment.