Fix feature gating the compare code.

This commit is contained in:
Tom Alexander 2023-08-10 20:21:39 -04:00
parent cd1b4ba785
commit 44ad6753ca
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 11 additions and 0 deletions

View File

@ -1,9 +1,13 @@
#![feature(round_char_boundary)]
use std::path::Path;
#[cfg(feature = "compare")]
use ::organic::parser::document;
#[cfg(feature = "compare")]
use organic::compare_document;
#[cfg(feature = "compare")]
use organic::emacs_parse_org_document;
#[cfg(feature = "compare")]
use organic::parser::sexp::sexp_with_padding;
use crate::init_tracing::init_telemetry;
@ -21,6 +25,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}
#[cfg(feature = "compare")]
fn run_compare<P: AsRef<Path>>(todo_org_path: P) -> Result<(), Box<dyn std::error::Error>> {
let org_contents = std::fs::read_to_string(todo_org_path.as_ref()).expect("Read org file.");
let (remaining, rust_parsed) = document(org_contents.as_str()).expect("Org Parse failure");
@ -49,3 +54,9 @@ fn run_compare<P: AsRef<Path>>(todo_org_path: P) -> Result<(), Box<dyn std::erro
Ok(())
}
#[cfg(not(feature = "compare"))]
fn run_compare<P: AsRef<Path>>(_todo_org_path: P) -> Result<(), Box<dyn std::error::Error>> {
println!("This program was built with compare disabled. Doing nothing.");
Ok(())
}