Skip to content

Commit

Permalink
[CLI] Implement the cli argument with the env value
Browse files Browse the repository at this point in the history
  • Loading branch information
MrVyM committed Nov 28, 2023
1 parent c04f370 commit a8da705
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
34 changes: 31 additions & 3 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,35 @@ use clap::Parser;
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
pub struct Args {
/// The url of the broker <mqtt://server:port>
#[arg(short, long)]
pub mqtt_server: String,
/// The url of the broker <mqtt://server:port>
#[arg(long, env)]
pub mqtt_server: String,

/// The minimum limit of the speed
#[arg(long, env)]
pub speed_limit_min: u16,

/// The maximum limit of the speed
#[arg(long, env)]
pub speed_limit_max: u16,

/// The diameter of the wheels
#[arg(long, env)]
pub wheel_diameter: u16,

/// The gaps between every wheels
#[arg(long, env)]
pub wheel_gaps: u16,

/// The value Kp Ki Kd rho theta phi
#[clap(long, value_parser, num_args = 6, value_delimiter = ' ', env)]
pub pid_linear: Vec<u8>,

/// TODO: Add argument
#[arg(long, env)]
pub lidar_pose: u16,

/// TODO: Add argument
#[arg(long, env)]
pub lidar_resolution: u16,
}
3 changes: 1 addition & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

pub mod cli;

use bevy::prelude::*;
Expand All @@ -12,6 +11,6 @@ fn hello_world() {
fn main() {
dotenvy::dotenv().ok();
let args = Args::parse();
println!("Hello {}!", args.mqtt_server);
println!("{:#?}", args);
App::new().add_systems(Startup, hello_world).run();
}

0 comments on commit a8da705

Please sign in to comment.