upgrade from structopt to clap 3

pull/309/head
Davide Bertola 2 years ago committed by Alessandro Decina
parent 68bc11e42c
commit cda9ab4f66

@ -6,7 +6,7 @@ edition = "2018"
[dependencies] [dependencies]
aya-gen = { path = "../aya-gen" } aya-gen = { path = "../aya-gen" }
structopt = {version = "0.3", default-features = false } clap = { version = "3", features = ["derive"] }
anyhow = "1" anyhow = "1"
syn = "1" syn = "1"
quote = "1" quote = "1"

@ -4,7 +4,7 @@ mod helpers;
use std::path::PathBuf; use std::path::PathBuf;
use structopt::StructOpt; use clap::Parser;
const SUPPORTED_ARCHS: &[Architecture] = &[ const SUPPORTED_ARCHS: &[Architecture] = &[
Architecture::X86_64, Architecture::X86_64,
@ -52,34 +52,34 @@ impl std::fmt::Display for Architecture {
} }
} }
#[derive(StructOpt)] #[derive(Parser)]
pub struct Options { pub struct Options {
#[structopt(long)] #[clap(long)]
libbpf_dir: PathBuf, libbpf_dir: PathBuf,
// sysroot options. Default to ubuntu headers installed by the // sysroot options. Default to ubuntu headers installed by the
// libc6-dev-{arm64,armel}-cross packages. // libc6-dev-{arm64,armel}-cross packages.
#[structopt(long, default_value = "/usr/include/x86_64-linux-gnu")] #[clap(long, default_value = "/usr/include/x86_64-linux-gnu")]
x86_64_sysroot: PathBuf, x86_64_sysroot: PathBuf,
#[structopt(long, default_value = "/usr/aarch64-linux-gnu/include")] #[clap(long, default_value = "/usr/aarch64-linux-gnu/include")]
aarch64_sysroot: PathBuf, aarch64_sysroot: PathBuf,
#[structopt(long, default_value = "/usr/arm-linux-gnueabi/include")] #[clap(long, default_value = "/usr/arm-linux-gnueabi/include")]
armv7_sysroot: PathBuf, armv7_sysroot: PathBuf,
#[structopt(long, default_value = "/usr/riscv64-linux-gnu/include")] #[clap(long, default_value = "/usr/riscv64-linux-gnu/include")]
riscv64_sysroot: PathBuf, riscv64_sysroot: PathBuf,
#[structopt(subcommand)] #[clap(subcommand)]
command: Option<Command>, command: Option<Command>,
} }
#[derive(StructOpt)] #[derive(Parser)]
enum Command { enum Command {
#[structopt(name = "aya")] #[clap(name = "aya")]
Aya, Aya,
#[structopt(name = "aya-bpf-bindings")] #[clap(name = "aya-bpf-bindings")]
AyaBpfBindings, AyaBpfBindings,
} }

@ -3,21 +3,21 @@ mod docs;
use std::process::exit; use std::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 {
Codegen(codegen::Options), Codegen(codegen::Options),
Docs, Docs,
} }
fn main() { fn main() {
let opts = Options::from_args(); let opts = Options::parse();
use Command::*; use Command::*;
let ret = match opts.command { let ret = match opts.command {

Loading…
Cancel
Save