Skip to main content

application

Attribute Macro application 

Source
#[application]
Expand description

Add a TUI application to a Clawless project

This macro attribute registers a function as a TUI application in a Clawless project. Unlike #[command], which creates a stateless CLI command rendered through a push-based presenter, #[application] creates a stateful TUI application that queries a pull-based projection.

Application functions must accept exactly three parameters:

  1. An args parameter: a clap::Args struct with the application’s arguments
  2. A context parameter: the Context for emitting events and cooperative shutdown
  3. A projection parameter: the Projection for querying accumulated state

§Attributes

  • alias = "name" - Add a visible alias for the application. Can be repeated.
  • require_subcommand - Require a subcommand; show help if invoked without one.

§Examples

use clawless::prelude::*;
use clawless::tui::projection::Projection;

#[derive(Debug, Args)]
pub struct DashboardArgs {
    #[arg(short, long, default_value = "3000")]
    port: u16,
}

/// Interactive project dashboard
#[application]
pub async fn dashboard(
    args: DashboardArgs,
    context: Context,
    projection: Projection,
) -> CommandResult {
    Ok(())
}