Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cbaacae9 authored by Mark Wheatley's avatar Mark Wheatley
Browse files

Migrate pdl from structopt to clap 3

Migrate the pdl tool from structopt to clap 3 and use the derive API.

Bug: 241573790
Test: m pdl + run `pdl --help`
Change-Id: I23fa9220208afa9e0832f94b1a25d3f13dd40d00
parent d95410d4
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -18,7 +18,7 @@ rust_defaults {
        "libquote",
        "libquote",
        "libserde",
        "libserde",
        "libserde_json",
        "libserde_json",
        "libstructopt",
        "libclap",
        "libsyn",
        "libsyn",
        "libtempfile",
        "libtempfile",
    ],
    ],
+1 −1
Original line number Original line Diff line number Diff line
@@ -13,7 +13,7 @@ proc-macro2 = "*"
quote = "*"
quote = "*"
serde = { version = "*", features = ["default", "derive", "serde_derive", "std"] }
serde = { version = "*", features = ["default", "derive", "serde_derive", "std"] }
serde_json = "*"
serde_json = "*"
structopt = "*"
clap = { version = "*", features = ["derive"] }
syn = "*"
syn = "*"


[dev-dependencies]
[dev-dependencies]
+6 −6
Original line number Original line Diff line number Diff line
//! PDL parser and linter.
//! PDL parser and linter.


use clap::Parser;
use codespan_reporting::term::{self, termcolor};
use codespan_reporting::term::{self, termcolor};
use structopt::StructOpt;


mod ast;
mod ast;
mod backends;
mod backends;
@@ -30,20 +30,20 @@ impl std::str::FromStr for OutputFormat {
    }
    }
}
}


#[derive(Debug, StructOpt)]
#[derive(Parser, Debug)]
#[structopt(name = "pdl-parser", about = "Packet Description Language parser tool.")]
#[clap(name = "pdl-parser", about = "Packet Description Language parser tool.")]
struct Opt {
struct Opt {
    /// Print tool version and exit.
    /// Print tool version and exit.
    #[structopt(short, long = "--version")]
    #[clap(short, long = "--version")]
    version: bool,
    version: bool,


    /// Generate output in this format ("json" or "rust"). The output
    /// Generate output in this format ("json" or "rust"). The output
    /// will be printed on stdout in both cases.
    /// will be printed on stdout in both cases.
    #[structopt(short, long = "--output-format", name = "FORMAT", default_value = "JSON")]
    #[clap(short, long = "--output-format", name = "FORMAT", default_value = "JSON")]
    output_format: OutputFormat,
    output_format: OutputFormat,


    /// Input file.
    /// Input file.
    #[structopt(name = "FILE")]
    #[clap(name = "FILE")]
    input_file: String,
    input_file: String,
}
}