summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 63dab998..f607422d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -39,6 +39,7 @@ fn try_main(args: Args) -> Result<()> {
Files => files(&args),
FilesParallel => files_parallel(&args),
Types => types(&args),
+ PCRE2Version => pcre2_version(&args),
}?;
if matched && (args.quiet() || !messages::errored()) {
process::exit(0)
@@ -275,3 +276,30 @@ fn types(args: &Args) -> Result<bool> {
}
Ok(count > 0)
}
+
+/// The top-level entry point for --pcre2-version.
+fn pcre2_version(args: &Args) -> Result<bool> {
+ #[cfg(feature = "pcre2")]
+ fn imp(args: &Args) -> Result<bool> {
+ use grep::pcre2;
+
+ let mut stdout = args.stdout();
+
+ let (major, minor) = pcre2::version();
+ writeln!(stdout, "PCRE2 {}.{} is available", major, minor)?;
+
+ if cfg!(target_pointer_width = "64") && pcre2::is_jit_available() {
+ writeln!(stdout, "JIT is available")?;
+ }
+ Ok(true)
+ }
+
+ #[cfg(not(feature = "pcre2"))]
+ fn imp(args: &Args) -> Result<bool> {
+ let mut stdout = args.stdout();
+ writeln!(stdout, "PCRE2 is not available in this build of ripgrep.")?;
+ Ok(false)
+ }
+
+ imp(args)
+}