28个版本
0.5.1 | 2024年2月19日 |
---|---|
0.4.12 | 2023年7月24日 |
0.4.6 | 2023年3月28日 |
0.3.5 | 2022年12月6日 |
0.1.0 | 2022年7月29日 |
#92 在 文件系统
22KB
372 行
FilesFinder
在尊重
.gitignore
的情况下查找匹配模式的文件
关于
FilesFinder (FF) 是一个旨在在给定存储库中搜索文件的命令行工具。因此,它尊重您的.gitignore
文件,并从输出中排除相同的文件。
FF是比其他工具(如来自Findutils的find
)更快且更易于使用的替代品。
注意:FF通常比
find
(或任何其他工具)更快,主要是因为它使用并行处理。如果您发现FF在某些情况下比find
或任何其他工具慢,请向我报告 :-)
安装
您可以使用cargo
安装最新发布的版本
cargo install filesfinder
之后,可以通过ff
别名使用FilesFinder
USAGE:
ff [OPTIONS] <PATTERN>...
ff [OPTIONS] <PATTERN> [OPTIONS] <PATTERN> ...
ARGS:
<PATTERN>...
A pattern to match against each file.
OPTIONS:
-g, -G
Parse pattern as a glob expression.
[default behavior]
-r, -R
Parse pattern as a regular expression.
Note that expressions are unanchored by default.
Use '^' or '\A' to denote start, and '$' or '\z' for the end.
-i, -I
Matching files will be included in the output.
[default behavior]
-e, -E
Matching files will be excluded from the output.
-j <JOBS>
Number of threads to use.
Setting this to zero will choose the number of threads automatically.
[default: num_cpus]
--dir <PATH>
Files will be searched in the directory specified by the PATH.
Multiple occurences are allowed.
[default: '.']
--max-depth <DEPTH>
Maximum depth to recurse.
[default: None]
--follow-links
Allow to follow symbolic links.
--show-hidden
Allow to show hidden files.
--no-gitignore
Ignore .gitignore files.
--no-ignore
Ignore .ignore files.
--no-strip-prefix
Do not strip './' prefix, same as what GNU find does.
-h, --help
Print help information.
-V, --version
Print version information.
NOTES:
- Capitalized options (.e.g., '-G') apply to all subsequent patterns.
E.g.: 'ff -g "*.rs" -g "*.md"' is equivalent to 'ff -G "*.rs" "*.md"'.
You can always unset a flag by overriding it.
- Options can be grouped under the same '-'.
E.g.: 'ff -e -g "*.rs"' is equivalent to 'ff -eg "*.rs"'.
- File exclusion is performed after file inclusion.
- For performance reasons, prefer to use more general patterns first,
and more specific ones at the end.
E.g.: 'ff "*.md" "Cargo.toml"' is (usually) faster but equivalent to 'ff "Cargo.toml" "*.md"'.
示例
> ff "*.rs"
# List all files with '.rs' extension
> ff "*.rs" -e "src/**.rs"
# List all files with 'rs' extension except those in the 'src' folder
> ff -r ".*\.md"
# List all files with 'md' extension, using regular expression
> ff -Re ".*\.md" ".*"
# List all files except those with 'md' extension, using regular expression
GitHub动作
FF的主要应用是在存储库中使用。因此,您还可以在项目中使用FilesFinder GitHub Action。
# Your action in .github/workflows
- name: Checkout repository
uses: actions/checkout@v3
# Repository name with owner. For example, actions/checkout
# Default: ${{ github.repository }}
repository: ''
- name: Find files matching "*.rs" or "*.md"
uses: jeertmans/filesfinder@latest
id: ff # Any id, to be used later to reference to files output
with:
# Only argument, a single string, to be passed as arguments to ff.
# See `ff --help` for more help.
# Default: "*"
args: "*.rs *.md"
- name: Print files
run: echo "${{ steps.ff.outputs.files }}"
贡献
欢迎贡献!
依赖
~8–19MB
~261K SLoC