ripgrepall(rga)是目前最好用的命令行搜索工具之一,不仅支持大量格式,甚至还能够通过编写adapter实现更多定制。
一个想法是把mdict-utls通过adapter集成到rga搜索,实现对mdx文件的全文搜索。
但目前连已有的案例我都没法正常实现。我配置了config.jsonc
配置文件:
"custom_adapters": [
{
"name": "xlsx2csv",
"version": 1,
"description": "Uses adaption of xlsx2csv (the Python package) to convert XLSX from STDIN to CSV files",
"extensions": ["xlsx"],
"mimetypes": ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],
"binary": "xlsx2csv",
"args": [ ],
"disabled_by_default": false,
"match_only_by_mime": false
}
]
试图用rga在1.xlsx中全文搜索John
❯ rga --rga-config-file='D:\HOME\.config\rga\config.jsonc' John 1.xlsx
但得到报错:
❯ rga --rga-config-file='D:\HOME\.config\rga\config.jsonc' John 1.xlsx
rg: 1.xlsx: preprocessor command failed: '"C:\\Users\\Administrator\\scoop\\apps\\rga\\current\\rga-preproc" "1.xlsx"':
-------------------------------------------------------------------------------
D:\HOME\.config\rga\1.xlsx adapter: xlsx2csv
D:\HOME\.config\rga\1.xlsx.txt adapter: postprocprefix
usage: xlsx2csv [-h] [-v] [-a] [-c OUTPUTENCODING] [-d DELIMITER]
[--hyperlinks] [-e] [--no-line-breaks]
[-E EXCLUDE_SHEET_PATTERN [EXCLUDE_SHEET_PATTERN ...]]
[-f DATEFORMAT] [-t TIMEFORMAT] [--floatformat FLOATFORMAT]
[--sci-float]
[-I INCLUDE_SHEET_PATTERN [INCLUDE_SHEET_PATTERN ...]]
[--exclude_hidden_sheets]
[--ignore-formats IGNORE_FORMATS [IGNORE_FORMATS ...]]
[-l LINETERMINATOR] [-m] [-n SHEETNAME] [-i]
[--skipemptycolumns] [-p SHEETDELIMITER] [-q QUOTING]
[-s SHEETID] [--include-hidden-rows]
xlsxfile [outfile]
xlsx2csv: error: the following arguments are required: xlsxfile
Error: copying adapter output to stdout
Caused by:
0: subprocess: Command { std: "xlsx2csv", kill_on_drop: false }
1: ExitStatus(ExitStatus(2))
-------------------------------------------------------------------------------
主要困惑在于
"args": [ ]
的参数写法binary
后来替换为脚本,但始终无法让Cygwin识别到这个脚本地址。