#line #duplicate #text #command-line-tool #directory #file #copypasta

app strainer

用于在文本文件中查找重复行的命令行工具

5 个版本 (破坏性更新)

0.5.0 2021 年 8 月 24 日
0.4.0 2021 年 5 月 30 日
0.3.0 2021 年 5 月 30 日
0.2.0 2021 年 5 月 30 日
0.1.0 2020 年 4 月 19 日

1593文本处理

ISC 许可证

30KB
562

Strainer:在项目中查找复制粘贴内容

Strainer 是一个命令行工具,它将递归地搜索目录中的文本文件,跟踪所有跨文件的重复行,并输出匹配行及其在每个文件中的位置。

安装

Strainer 可在 crates.io 上获取

cargo install strainer

它有一个编译时功能标志:syntax-highlighting。启用此功能后,将使用 syntect 库自动在输出中为代码行进行语法高亮。这将使二进制文件大小大致翻倍(但仍然很小),且在默认的 macOS 终端应用程序中颜色显示不正确(但 iTerm2 可以正常工作)。

cargo install strainer --features "syntax-highlighting"

使用方法

USAGE:
    strainer [FLAGS] [OPTIONS] <DIRECTORY>

FLAGS:
    -h, --help                 Prints help information
    -r, --remove_duplicates    Remove duplicate lines (keep the first occurrence). Requires --same_file. DANGER:
                               Overwrites source files, use with caution!
    -s, --same_file            Only check for duplicate lines within the same file.
    -t, --trim_whitespace      Trim whitespace from the start and end of each line before comparing.
    -V, --version              Prints version information

OPTIONS:
    -d, --line_delimiter <CHAR>             The character that delimits 'lines'. Can be used, for example, to search a
                                            natural-language file by passing '.' to split on sentences. [default: \n]
    -l, --line_pattern <PAT>                A basic pattern string to filter which lines will show up in results.
                                            Asterisks ('*') will match any substring. [default: *]
    -p, --path_pattern <PAT>                A basic pattern string to filter which files will be searched. Asterisks
                                            ('*') will match any substring. [default: *]
    -s, --squash_chars <squash_chars>...    Characters that should be 'squashed' when processing a line. When a
                                            character is 'squashed', any continuous sequence of that character will be
                                            treated as a single instance. This cen be used to, for example, normalize
                                            indentation. [default: false]

ARGS:
    <DIRECTORY>    The root directory to search within

依赖项

~1–10MB
~69K SLoC