ClingFinished

Type Alias ClingFinished 

Source
pub type ClingFinished<T> = Cling<T, Finished>;
Expand description

A completed run of a cling program.

This is typically used to introspect the result after running the cling application, but since it implements Termination trait, it can be used as a return type in main() directly.

use cling::prelude::*;

#[derive(Run, Parser, Debug, Clone)]
#[cling(run = "run")]
pub struct App {
    /// Turn debugging information on
    #[arg(short, long, action = ArgAction::Count)]
    pub debug: u8,
}

fn run() {
    println!("Hello Program!");
}

// Note that tokio here is only used as an example, you can use any async runtime.
#[tokio::main]
async fn main() -> ClingFinished<App> {
    Cling::parse_and_run().await
}

Aliased Type§

pub struct ClingFinished<T> { /* private fields */ }

Trait Implementations§

Source§

impl<T: Run + Parser> From<CliError> for ClingFinished<T>

Convert a CliError into a ClingFinished.

Source§

fn from(value: CliError) -> Self

Converts to this type from the input type.
Source§

impl<T: Run + Parser> Termination for ClingFinished<T>

Allows main() to return ClingFinished and it’ll report the error correctly if any.

Source§

fn report(self) -> ExitCode

Is called to get the representation of the value as status code. This status code is returned to the operating system.