Expand description
Runtime helper for sync CLI wrappers
This module provides utilities for executing async operations in sync CLI contexts. Required because clap-noun-verb v3.4.0 uses sync verb functions, but business logic may require async operations (file I/O, network requests, etc.).
§Examples
ⓘ
use cli::runtime_helper::execute_async;
use clap_noun_verb::Result;
fn my_sync_command() -> Result<Output> {
execute_async(async {
// Async business logic here
let result = async_operation().await?;
Ok(result)
})
.map_err(|e| clap_noun_verb::NounVerbError::execution_error(e.to_string()))
}Functions§
- create_
runtime - Create a new tokio runtime for async operations in sync context
- execute_
async - Execute an async function in a sync context
- execute_
async_ verb - Execute an async function and convert errors to clap_noun_verb::NounVerbError