Merge pull request #41 from vadorovsky/clap

Use clap instead of structopt
pull/43/head
Alessandro Decina 3 years ago committed by GitHub
commit 1f179c0af1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -8,10 +8,12 @@ publish = false
aya = { git = "https://github.com/aya-rs/aya", branch="main" } aya = { git = "https://github.com/aya-rs/aya", branch="main" }
{{project-name}}-common = { path = "../{{project-name}}-common", features=["user"] } {{project-name}}-common = { path = "../{{project-name}}-common", features=["user"] }
anyhow = "1.0.42" anyhow = "1.0.42"
{% if program_type == "uprobe" %}libc = "0.2.102"{% endif %} clap = { version = "3.1", features = ["derive"] }
{%- if program_type == "uprobe" %}
libc = "0.2.102"
{%- endif %}
log = "0.4" log = "0.4"
simplelog = "0.12" simplelog = "0.12"
structopt = { version = "0.3" }
tokio = { version = "1.18", features = ["macros", "rt", "rt-multi-thread", "net", "signal"] } tokio = { version = "1.18", features = ["macros", "rt", "rt-multi-thread", "net", "signal"] }
[[bin]] [[bin]]

@ -28,28 +28,28 @@ use aya::{programs::Lsm, Btf};
{%- when "tp_btf" -%} {%- when "tp_btf" -%}
use aya::{programs::BtfTracePoint, Btf}; use aya::{programs::BtfTracePoint, Btf};
{%- endcase %} {%- endcase %}
use clap::Parser;
use log::info; use log::info;
use simplelog::{ColorChoice, ConfigBuilder, LevelFilter, TermLogger, TerminalMode}; use simplelog::{ColorChoice, ConfigBuilder, LevelFilter, TermLogger, TerminalMode};
use structopt::StructOpt;
use tokio::signal; use tokio::signal;
#[derive(Debug, StructOpt)] #[derive(Debug, Parser)]
struct Opt { struct Opt {
{% if program_type == "xdp" or program_type == "classifier" -%} {% if program_type == "xdp" or program_type == "classifier" -%}
#[structopt(short, long, default_value = "eth0")] #[clap(short, long, default_value = "eth0")]
iface: String, iface: String,
{%- elsif program_type == "sock_ops" or program_type == "cgroup_skb" -%} {%- elsif program_type == "sock_ops" or program_type == "cgroup_skb" -%}
#[structopt(short, long, default_value = "/sys/fs/cgroup/unified")] #[clap(short, long, default_value = "/sys/fs/cgroup/unified")]
cgroup_path: String, cgroup_path: String,
{%- elsif program_type == "uprobe" or program_type == "uretprobe" -%} {%- elsif program_type == "uprobe" or program_type == "uretprobe" -%}
#[structopt(short, long)] #[clap(short, long)]
pid: Option<i32> pid: Option<i32>
{%- endif %} {%- endif %}
} }
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), anyhow::Error> { async fn main() -> Result<(), anyhow::Error> {
let opt = Opt::from_args(); let opt = Opt::parse();
TermLogger::init( TermLogger::init(
LevelFilter::Debug, LevelFilter::Debug,

Loading…
Cancel
Save