Make compare an always-async program.

This program is used as a development tool, so it is more valuable that we make it simple by only supporting one mode of operation (async) than making it widely compatible by supporting both.
This commit is contained in:
Tom Alexander 2023-10-14 17:43:49 -04:00
parent 74a3512038
commit c20e7b5f2f
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 9 additions and 4 deletions

View File

@ -53,8 +53,8 @@ walkdir = { version = "2.3.3", optional = true }
walkdir = "2.3.3"
[features]
default = []
compare = []
default = ["compare", "foreign_document_test"]
compare = ["dep:tokio"]
foreign_document_test = ["compare", "dep:tokio", "dep:futures", "tokio/sync", "dep:walkdir"]
tracing = ["dep:opentelemetry", "dep:opentelemetry-otlp", "dep:opentelemetry-semantic-conventions", "dep:tokio", "dep:tracing", "dep:tracing-opentelemetry", "dep:tracing-subscriber"]

View File

@ -14,7 +14,12 @@ mod init_tracing;
#[cfg(not(feature = "tracing"))]
fn main() -> Result<(), Box<dyn std::error::Error>> {
main_body()
let rt = tokio::runtime::Runtime::new()?;
let result = rt.block_on(async {
let main_body_result = main_body().await;
main_body_result
});
result
}
#[cfg(feature = "tracing")]
@ -30,7 +35,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
}
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn main_body() -> Result<(), Box<dyn std::error::Error>> {
async fn main_body() -> Result<(), Box<dyn std::error::Error>> {
let args = std::env::args().skip(1);
if args.is_empty() {
let org_contents = read_stdin_to_string()?;