Crates.io | bevy_console |
lib.rs | bevy_console |
version | |
source | src |
created_at | 2021-04-19 14:51:34.35951 |
updated_at | 2024-12-02 22:31:06.092164 |
description | dev console for bevy |
homepage | https://github.com/RichoDemus/bevy-console |
repository | https://github.com/RichoDemus/bevy-console |
max_upload_size | |
id | 386695 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A simple Half-Life inspired console with support for argument parsing powered by clap
.
clap
Add ConsolePlugin
and optionally the resource ConsoleConfiguration
.
use bevy::prelude::*;
use bevy_console::{ConsoleConfiguration, ConsolePlugin};
fn main() {
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_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
Should work in wasm, but you need to disable default features.