#query-string #command-line-arguments #query-parameters #arguments-parser #bevy-plugin #bevy #args

bevy_args

bevy plugin to parse command line arguments and URL query parameters

11 stable releases

new 1.7.0 Nov 30, 2024
1.6.1 Nov 15, 2024
1.6.0 Jul 18, 2024
1.4.2 May 15, 2024
1.2.0 Jan 26, 2024

#302 in Game dev

Download history 40/week @ 2024-08-23 21/week @ 2024-08-30 12/week @ 2024-09-06 2/week @ 2024-09-13 33/week @ 2024-09-20 64/week @ 2024-09-27 14/week @ 2024-10-04 58/week @ 2024-10-11 42/week @ 2024-10-18 16/week @ 2024-10-25 61/week @ 2024-11-01 15/week @ 2024-11-08 142/week @ 2024-11-15 104/week @ 2024-11-22 210/week @ 2024-11-29

477 downloads per month
Used in 9 crates

MIT license

17KB
89 lines

bevy_args 🧩

test GitHub License GitHub Last Commit GitHub Releases GitHub Issues Average time to resolve an issue 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.7 0.15
1.5 0.14
1.3 0.13
1.0 0.12

Dependencies

~30–42MB
~692K SLoC