Attribute Macro indigo::main[][src]

#[main]

Defines an async main function that runs on the Indigo runtime.

Example

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.

#[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.

#[derive(Debug, StructOpt)]
struct Options {
  #[structopt(short, long)]
  verbose: bool,
}

#[indigo::main]
async fn main(options: Options) {
  println!("{:#?}", options);
}