Attribute Macro main

Source
#[main]
Expand description

An attribute macro that defines an entry point to a Cot-powered app.

This macro is meant to wrap a function returning a structure implementing [CotProject]. It should just initialize a [CotProject] and return it, while the macro takes care of initializing an async runtime, creating a CLI and running the app.

ยงExamples

use cot::project::WithConfig;
use cot::{App, AppBuilder, Project, ProjectContext};

struct HelloApp;

impl App for HelloApp {
    fn name(&self) -> &'static str {
        env!("CARGO_PKG_NAME")
    }
}

struct HelloProject;
impl Project for HelloProject {
    fn register_apps(&self, apps: &mut AppBuilder, _context: &ProjectContext<WithConfig>) {
        apps.register_with_views(HelloApp, "");
    }
}

#[cot::main]
fn main() -> impl Project {
    HelloProject
}