update aya-gen from structopt to clap 3

pull/297/head
Davide Bertola 3 years ago
parent ddf26300c8
commit ad93b7da7f

@ -6,7 +6,7 @@ edition = "2018"
[dependencies] [dependencies]
bindgen = "0.60" bindgen = "0.60"
structopt = {version = "0.3", default-features = false } clap = { version = "3", features = ["derive"] }
anyhow = "1" anyhow = "1"
thiserror = "1" thiserror = "1"
syn = "1" syn = "1"

@ -2,18 +2,19 @@ use aya_gen::btf_types;
use std::{path::PathBuf, process::exit}; use std::{path::PathBuf, process::exit};
use structopt::StructOpt; use clap::Parser;
#[derive(StructOpt)]
#[derive(Parser)]
pub struct Options { pub struct Options {
#[structopt(subcommand)] #[clap(subcommand)]
command: Command, command: Command,
} }
#[derive(StructOpt)] #[derive(Parser)]
enum Command { enum Command {
#[structopt(name = "btf-types")] #[clap(name = "btf-types")]
BtfTypes { BtfTypes {
#[structopt(long, default_value = "/sys/kernel/btf/vmlinux")] #[clap(long, default_value = "/sys/kernel/btf/vmlinux")]
btf: PathBuf, btf: PathBuf,
names: Vec<String>, names: Vec<String>,
}, },
@ -27,7 +28,7 @@ fn main() {
} }
fn try_main() -> Result<(), anyhow::Error> { fn try_main() -> Result<(), anyhow::Error> {
let opts = Options::from_args(); let opts = Options::parse();
match opts.command { match opts.command {
Command::BtfTypes { btf, names } => { Command::BtfTypes { btf, names } => {
let bindings = btf_types::generate(&btf, &names)?; let bindings = btf_types::generate(&btf, &names)?;

Loading…
Cancel
Save