diff --git a/src/bin_compare.rs b/src/bin_compare.rs index 087c2c5..428117c 100644 --- a/src/bin_compare.rs +++ b/src/bin_compare.rs @@ -1,3 +1,4 @@ +#![feature(exit_status_error)] #![feature(round_char_boundary)] #![feature(exact_size_is_empty)] use std::io::Read; @@ -5,6 +6,8 @@ use std::io::Read; use organic::compare::run_anonymous_compare; use organic::compare::run_compare_on_file; +mod util; + #[cfg(feature = "tracing")] use crate::init_tracing::init_telemetry; #[cfg(feature = "tracing")] diff --git a/src/compare/compare.rs b/src/compare/compare.rs index 756dcb7..d0f7bf2 100644 --- a/src/compare/compare.rs +++ b/src/compare/compare.rs @@ -4,13 +4,12 @@ use crate::compare::diff::compare_document; use crate::compare::diff::DiffResult; use crate::compare::parse::emacs_parse_anonymous_org_document; use crate::compare::parse::emacs_parse_file_org_document; -use crate::compare::parse::get_emacs_version; -use crate::compare::parse::get_org_mode_version; use crate::compare::sexp::sexp; use crate::context::GlobalSettings; use crate::context::LocalFileAccessInterface; use crate::parser::parse_file_with_settings; use crate::parser::parse_with_settings; +use crate::util::print_versions; pub async fn run_anonymous_compare>( org_contents: P, @@ -128,12 +127,3 @@ pub async fn run_compare_on_file_with_settings<'g, 's, P: AsRef>( Ok(true) } - -async fn print_versions() -> Result<(), Box> { - eprintln!("Using emacs version: {}", get_emacs_version().await?.trim()); - eprintln!( - "Using org-mode version: {}", - get_org_mode_version().await?.trim() - ); - Ok(()) -} diff --git a/src/compare/mod.rs b/src/compare/mod.rs index a19cd3c..5a2c30e 100644 --- a/src/compare/mod.rs +++ b/src/compare/mod.rs @@ -7,7 +7,6 @@ mod macros; mod parse; mod sexp; mod util; -pub(crate) use compare::print_versions; pub use compare::run_anonymous_compare; pub use compare::run_anonymous_compare_with_settings; pub use compare::run_compare_on_file; diff --git a/src/compare/parse.rs b/src/compare/parse.rs index 8b28fc3..1c5c770 100644 --- a/src/compare/parse.rs +++ b/src/compare/parse.rs @@ -143,40 +143,3 @@ where } output } - -pub async fn get_emacs_version() -> Result> { - let elisp_script = r#"(progn - (message "%s" (version)) -)"#; - let mut cmd = Command::new("emacs"); - let cmd = cmd - .arg("-q") - .arg("--no-site-file") - .arg("--no-splash") - .arg("--batch") - .arg("--eval") - .arg(elisp_script); - - let out = cmd.output().await?; - out.status.exit_ok()?; - Ok(String::from_utf8(out.stderr)?) -} - -pub async fn get_org_mode_version() -> Result> { - let elisp_script = r#"(progn - (org-mode) - (message "%s" (org-version nil t nil)) -)"#; - let mut cmd = Command::new("emacs"); - let cmd = cmd - .arg("-q") - .arg("--no-site-file") - .arg("--no-splash") - .arg("--batch") - .arg("--eval") - .arg(elisp_script); - - let out = cmd.output().await?; - out.status.exit_ok()?; - Ok(String::from_utf8(out.stderr)?) -} diff --git a/src/lib.rs b/src/lib.rs index 6795061..c1451cd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,6 +10,8 @@ extern crate test; #[cfg(feature = "compare")] pub mod compare; +#[cfg(feature = "compare")] +mod util; mod context; mod error;