3 unstable releases
Uses new Rust 2024
| 0.2.0 | Oct 17, 2025 |
|---|---|
| 0.1.1 | Oct 10, 2025 |
| 0.1.0 | Oct 9, 2025 |
#1260 in Game dev
49KB
742 lines
bevy_commodore
This is a text command framework for Bevy, largely inspired by Minecraft's Brigadier command parser & dispatcher.
Features
- Multiple simultaneous command and argument registries
- Custom argument types
- Optional arguments
- (Nested) subcommands
Getting started
To start, simply register your commands to your CommandPlugin plugin and add it to the app, e.g.:
use bevy::{DefaultPlugins, app::App};
use bevy_commodore::{CommandBuilder, CommandContext, CommandPlugin, CommandResult};
use std::fmt::Write;
fn echo_command_handler(In(mut ctx): In<CommandContext>) -> CommandResult {
let input = *tx.argument::<String>("input");
_ = writeln!(ctx, "{input}");
CommandResult::Ok
}
let mut app = App::new();
let plugin = CommandPlugin::<(), ()>::new();
let echo_command = CommandBuilder::new("echo", Some("Echoes the input text back to the user"), echo_command_handler);
echo_command.with_argument::<String>("input", None, false);
plugin.register_command(plugin);
app.add_plugins(DefaultPlugins);
app.add_plugins(plugin);
app.run();
[!NOTE] This example will work, but it will provide no way to call these commands. To supply input to the command plugin, use the
CommandInputevent. You'll be able to get the result of the command via theCommandOutputevent.
For a more detailed and fully functional example showcasing more features, you can view the examples/example.rs file.
Roadmap
- Variadic arguments
- Help for subcommands
Dependencies
~21–34MB
~557K SLoC