[−][src]Attribute Macro indigo_proc_macros::runtime_main
#[runtime_main]
Defines an async main function that runs on the Indigo runtime.
Example
ⓘThis example is not tested
use indigo::prelude::*; #[indigo::main] async fn main() { println!("Hello Indigo!"); }
Returning a result
The main
function may return a Result<(), T>
. If the return value is an
Err(T)
the error is written to stderr and the process exits with an exit
code of 1
.
ⓘThis example is not tested
#[indigo::main] async fn main() -> Result<(), String> { Err("This message is written to stderr.".into()) }
Parsing command-line arguments
Requires the cli
feature.
The main
function may optionally have one parameter. If this parameter
implements StructOpt
, it is parsed from the command-line arguments.
ⓘThis example is not tested
#[derive(Debug, StructOpt)] struct Options { #[structopt(short, long)] verbose: bool, } #[indigo::main] async fn main(options: Options) { println!("{:#?}", options); }