leafwing_terminal

A simple virtual terminal for Bevy games with support for argument parsing.

Usage

Add TerminalPlugin and optionally the resource TerminalConfiguration.

use bevy::prelude::*;
use leafwing_terminal::{TerminalConfiguration, TerminalPlugin};

fn main() {
    App::new()
        .add_plugin(TerminalPlugin)
        .insert_resource(TerminalConfiguration {
            // override config here
            ..Default::default()
        });
}

Create a terminal command struct and system and add it to your app with .add_terminal_command.

Add doc comments to your command to provide help information in the terminal.

use bevy::prelude::*;
use leafwing_terminal::{reply, AddTerminalCommand, TerminalCommand, TerminalPlugin};

fn main() {
    App::new()
        .add_plugin(TerminalPlugin)
        .add_terminal_command::<ExampleCommand, _, _>(example_command);
}

/// Example command
#[derive(TerminalCommand)]
#[terminal_command(name = "example")]
struct ExampleCommand {
    /// Some message
    msg: String,
}

fn example_command(mut log: TerminalCommand<ExampleCommand>) {
    if let Some(ExampleCommand { msg }) = log.take() {
        // handle command
    }
}

Examples can be found in the /examples directory.

cargo run --example log_command

wasm

Should work in wasm, but you need to disable default features.