Skip to content
 
 

Latest commit

 

History

82 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bevy_headless_console

Check

A headless console with support for argument parsing powered by clap, forked from bevy_console without egui, so that the user can wire up their own console interface.

Usage

Add ConsolePlugin and optionally the resource ConsoleConfiguration.

use bevy::prelude::*;
use bevy_headless_console::{ConsoleConfiguration, ConsolePlugin};

App::new()
    .add_plugins((DefaultPlugins, ConsolePlugin))
    .insert_resource(ConsoleConfiguration {
        // override config here
        ..Default::default()
    });

Create a console command struct and system and add it to your app with .add_console_command. Commands are created like clap commands with an additional CommandName trait derived via the ConsoleCommand derive.

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

use bevy::prelude::*;
use bevy_headless_console::{reply, AddConsoleCommand, ConsoleCommand, ConsolePlugin};
use clap::Parser;

fn main() {
    App::new()
        .add_plugins((DefaultPlugins, ConsolePlugin))
        .add_console_command::<ExampleCommand, _>(example_command);
}

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

fn example_command(mut log: ConsoleCommand<ExampleCommand>) {
    if let Some(Ok(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.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages