mirror of
https://github.com/FliegendeWurst/ripgrep-all.git
synced 2024-11-08 14:00:37 +00:00
flexible
This commit is contained in:
parent
523baf6db2
commit
98ea929978
@ -44,12 +44,12 @@ pub struct CustomAdapterConfig {
|
|||||||
/// The arguments to run the program with. Placeholders:
|
/// The arguments to run the program with. Placeholders:
|
||||||
/// - $input_file_extension: the file extension (without dot). e.g. foo.tar.gz -> gz
|
/// - $input_file_extension: the file extension (without dot). e.g. foo.tar.gz -> gz
|
||||||
/// - $input_file_stem, the file name without the last extension. e.g. foo.tar.gz -> foo.tar
|
/// - $input_file_stem, the file name without the last extension. e.g. foo.tar.gz -> foo.tar
|
||||||
/// - $input_path: the full input file path
|
/// - $input_virtual_path: the full input file path. Note that this path may not actually exist on disk because it is the result of another adapter
|
||||||
/// stdin of the program will be connected to the input file, and stdout is assumed to be the converted file
|
/// stdin of the program will be connected to the input file, and stdout is assumed to be the converted file
|
||||||
pub args: Vec<String>,
|
pub args: Vec<String>,
|
||||||
/// The output path hint. The placeholders are the same as for `.args`
|
/// The output path hint. The placeholders are the same as for `.args`
|
||||||
///
|
///
|
||||||
/// If not set, defaults to ${input_path}.txt
|
/// If not set, defaults to ${input_virtual_path}.txt
|
||||||
///
|
///
|
||||||
pub output_path_hint: Option<String>,
|
pub output_path_hint: Option<String>,
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ lazy_static! {
|
|||||||
args: strs(&["-", "-"]),
|
args: strs(&["-", "-"]),
|
||||||
disabled_by_default: None,
|
disabled_by_default: None,
|
||||||
match_only_by_mime: None,
|
match_only_by_mime: None,
|
||||||
output_path_hint: Some("${input_path}.txt.asciipagebreaks".into())
|
output_path_hint: Some("${input_virtual_path}.txt.asciipagebreaks".into())
|
||||||
// postprocessors: [{name: "add_page_numbers_by_pagebreaks"}]
|
// postprocessors: [{name: "add_page_numbers_by_pagebreaks"}]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
@ -196,7 +196,7 @@ impl GetMetadata for CustomSpawningFileAdapter {
|
|||||||
}
|
}
|
||||||
fn arg_replacer(arg: &str, filepath_hint: &Path) -> Result<String> {
|
fn arg_replacer(arg: &str, filepath_hint: &Path) -> Result<String> {
|
||||||
expand_str_ez(arg, |s| match s {
|
expand_str_ez(arg, |s| match s {
|
||||||
"input_path" => Ok(filepath_hint.to_string_lossy()),
|
"input_virtual_path" => Ok(filepath_hint.to_string_lossy()),
|
||||||
"input_file_stem" => Ok(filepath_hint
|
"input_file_stem" => Ok(filepath_hint
|
||||||
.file_stem()
|
.file_stem()
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
@ -250,7 +250,7 @@ impl FileAdapter for CustomSpawningFileAdapter {
|
|||||||
filepath_hint: PathBuf::from(arg_replacer(
|
filepath_hint: PathBuf::from(arg_replacer(
|
||||||
self.output_path_hint
|
self.output_path_hint
|
||||||
.as_deref()
|
.as_deref()
|
||||||
.unwrap_or("${input_path}.txt"),
|
.unwrap_or("${input_virtual_path}.txt"),
|
||||||
&filepath_hint,
|
&filepath_hint,
|
||||||
)?),
|
)?),
|
||||||
inp: output,
|
inp: output,
|
||||||
|
Loading…
Reference in New Issue
Block a user