Skip to main content

Module runtime_helper

Module runtime_helper 

Source
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