#arg #bevy #resources #query-parameters #cli

bevy_args

bevy plugin to parse command line arguments and URL query parameters

13 stable releases

new 1.8.0 Apr 25, 2025
1.7.1 Feb 14, 2025
1.7.0 Nov 30, 2024
1.6.0 Jul 18, 2024
1.2.0 Jan 26, 2024

#331 in Game dev

Download history 31/week @ 2025-01-08 2/week @ 2025-01-15 7/week @ 2025-01-22 21/week @ 2025-01-29 30/week @ 2025-02-05 220/week @ 2025-02-12 31/week @ 2025-02-19 77/week @ 2025-02-26 9/week @ 2025-03-05 11/week @ 2025-03-12 2/week @ 2025-03-19 8/week @ 2025-03-26 16/week @ 2025-04-02 5/week @ 2025-04-09 45/week @ 2025-04-16

75 downloads per month
Used in 10 crates

MIT license

14KB
89 lines

bevy_args 🧩

test GitHub License crates.io

bevy plugin to parse command line arguments and URL query parameters into resources

command line arguments

cargo run --example=minimal -- --my-string hello --my-int 42 --my-bool --my-enum another-value

URL query parameters

http://localhost:8080/?my_string=hello&my_int=42&my_bool=true&my_enum=AnotherValue

minimal example

use bevy_args::BevyArgsPlugin;


#[derive(
    Default,
    Debug,
    Resource,
    Serialize,
    Deserialize,
    Parser,
)]
#[command(about = "a minimal example of bevy_args", version, long_about = None)]
pub struct MinimalArgs {
    #[arg(long, default_value = "hello")]
    pub my_string: String,

    #[arg(long, default_value = "42")]
    pub my_int: i32,

    #[arg(long)]
    pub my_bool: bool,
}


pub fn main() {
    let mut app = App::new();

    app.add_plugins(BevyArgsPlugin::<MinimalArgs>::default());
    app.add_systems(Startup, print_minimal_args);

    app.run();
}

fn print_minimal_args(args: Res<MinimalArgs>) {
    println!("{:?}", *args);
}

compatible bevy versions

bevy_args bevy
1.8 0.16
1.7 0.15
1.5 0.14
1.3 0.13
1.0 0.12

Dependencies

~26–35MB
~600K SLoC