diff --git a/xtask/src/build_ebpf.rs b/xtask/src/build_ebpf.rs index 8b32804..25c4f06 100644 --- a/xtask/src/build_ebpf.rs +++ b/xtask/src/build_ebpf.rs @@ -1,5 +1,4 @@ -use std::path::PathBuf; -use std::process::Command; +use std::{path::PathBuf, process::Command}; use clap::Parser; @@ -55,7 +54,7 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> { args.push("--release") } let status = Command::new("cargo") - .current_dir(&dir) + .current_dir(dir) .args(&args) .status() .expect("failed to build bpf program"); diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 59d5f88..c1c594e 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -27,7 +27,7 @@ fn main() { }; if let Err(e) = ret { - eprintln!("{:#}", e); + eprintln!("{e:#}"); exit(1); } } diff --git a/xtask/src/run.rs b/xtask/src/run.rs index afa6928..55a9806 100644 --- a/xtask/src/run.rs +++ b/xtask/src/run.rs @@ -47,7 +47,7 @@ pub fn run(opts: Options) -> Result<(), anyhow::Error> { // profile we are building (release or debug) let profile = if opts.release { "release" } else { "debug" }; - let bin_path = format!("target/{}/{{project-name}}", profile); + let bin_path = format!("target/{profile}/{{project-name}}"); // arguments to pass to the application let mut run_args: Vec<_> = opts.run_args.iter().map(String::as_str).collect(); @@ -58,7 +58,7 @@ pub fn run(opts: Options) -> Result<(), anyhow::Error> { args.append(&mut run_args); // spawn the command - let err = Command::new(args.get(0).expect("No first argument")) + let err = Command::new(args.first().expect("No first argument")) .args(args.iter().skip(1)) .exec(); diff --git a/{{project-name}}/src/main.rs b/{{project-name}}/src/main.rs index a16a6ef..f292fa5 100644 --- a/{{project-name}}/src/main.rs +++ b/{{project-name}}/src/main.rs @@ -41,6 +41,9 @@ use clap::Parser; use log::{info, warn}; use tokio::signal; +{% case program_type %} +{%- when + "xdp", "classifier", "sock_ops", "cgroup_skb", "cgroup_sysctl", "cgroup_sockopt", "uprobe", "uretprobe" -%} #[derive(Debug, Parser)] struct Opt { {% if program_type == "xdp" or program_type == "classifier" -%} @@ -54,11 +57,17 @@ struct Opt { pid: Option {%- endif %} } +{%- endcase %} #[tokio::main] async fn main() -> Result<(), anyhow::Error> { + {% case program_type %} + {%- when + "xdp", "classifier", "sock_ops", "cgroup_skb", "cgroup_sysctl", "cgroup_sockopt", "uprobe", "uretprobe" -%} let opt = Opt::parse(); + {%- endcase %} + env_logger::init(); // This will include your eBPF object file as raw bytes at compile-time and load it at