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

Commit e7d9f704 authored by David Duarte's avatar David Duarte Committed by Martin Geisler
Browse files

Revert "Prepare for clap 4."

This reverts commit 5af36d0b70b427a5d310a1f5a4a632877672e5ca.

Merged-In: I23fa9220208afa9e0832f94b1a25d3f13dd40d00
Change-Id: I3c59487086a6758aad0dbf57295acaa25fa82f93
Test: m
Tag: #refactor
Bug: 228306436
parent 50b5acda
Loading
Loading
Loading
Loading
+17 −22
Original line number Diff line number Diff line
//! Starts the facade services that allow us to test the Bluetooth stack

use bluetooth_with_facades::RootFacadeService;
use clap::{value_parser, Arg, Command};
use clap::{value_t, App, Arg};
use futures::channel::mpsc;
use futures::executor::block_on;
use futures::stream::StreamExt;
@@ -20,42 +20,37 @@ fn main() {
}

async fn async_main(rt: Arc<Runtime>, mut sigint: mpsc::UnboundedReceiver<()>) {
    let matches = Command::new("bluetooth_with_facades")
    let matches = App::new("bluetooth_with_facades")
        .about("The bluetooth stack, with testing facades enabled and exposed via gRPC.")
        .arg(
            Arg::new("root-server-port")
            Arg::with_name("root-server-port")
                .long("root-server-port")
                .value_parser(value_parser!(u16))
                .default_value("8897"),
                .default_value("8897")
                .takes_value(true),
        )
        .arg(Arg::with_name("grpc-port").long("grpc-port").default_value("8899").takes_value(true))
        .arg(
            Arg::new("grpc-port")
                .long("grpc-port")
                .value_parser(value_parser!(u16))
                .default_value("8899"),
        )
        .arg(
            Arg::new("signal-port")
            Arg::with_name("signal-port")
                .long("signal-port")
                .value_parser(value_parser!(u16))
                .default_value("8895"),
                .default_value("8895")
                .takes_value(true),
        )
        .arg(Arg::new("rootcanal-port").long("rootcanal-port").value_parser(value_parser!(u16)))
        .arg(Arg::new("btsnoop").long("btsnoop"))
        .arg(Arg::new("btsnooz").long("btsnooz"))
        .arg(Arg::new("btconfig").long("btconfig"))
        .arg(Arg::with_name("rootcanal-port").long("rootcanal-port").takes_value(true))
        .arg(Arg::with_name("btsnoop").long("btsnoop").takes_value(true))
        .arg(Arg::with_name("btsnooz").long("btsnooz").takes_value(true))
        .arg(Arg::with_name("btconfig").long("btconfig").takes_value(true))
        .get_matches();

    let root_server_port = *matches.get_one::<u16>("root-server-port").unwrap();
    let grpc_port = *matches.get_one::<u16>("grpc-port").unwrap();
    let rootcanal_port = matches.get_one::<u16>("rootcanal-port").copied();
    let root_server_port = value_t!(matches, "root-server-port", u16).unwrap();
    let grpc_port = value_t!(matches, "grpc-port", u16).unwrap();
    let rootcanal_port = value_t!(matches, "rootcanal-port", u16).ok();
    let env = Arc::new(Environment::new(2));
    let mut server = ServerBuilder::new(env)
        .register_service(RootFacadeService::create(
            rt,
            grpc_port,
            rootcanal_port,
            matches.get_one::<String>("btsnoop").cloned(),
            matches.value_of("btsnoop").map(String::from),
        ))
        .bind("0.0.0.0", root_server_port)
        .build()
+19 −24
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@

use bt_topshim::btif;

use clap::{value_parser, Arg, Command};
use clap::{value_t, App, Arg};
use futures::channel::mpsc;
use futures::executor::block_on;
use futures::stream::StreamExt;
@@ -36,40 +36,35 @@ fn main() {
}

async fn async_main(rt: Arc<Runtime>, mut sigint: mpsc::UnboundedReceiver<()>) {
    let matches = Command::new("bluetooth_topshim_facade")
    let matches = App::new("bluetooth_topshim_facade")
        .about("The bluetooth topshim stack, with testing facades enabled and exposed via gRPC.")
        .arg(Arg::with_name("grpc-port").long("grpc-port").default_value("8899").takes_value(true))
        .arg(
            Arg::new("grpc-port")
                .long("grpc-port")
                .value_parser(value_parser!(u16))
                .default_value("8899"),
        )
        .arg(
            Arg::new("root-server-port")
            Arg::with_name("root-server-port")
                .long("root-server-port")
                .value_parser(value_parser!(u16))
                .default_value("8897"),
                .default_value("8897")
                .takes_value(true),
        )
        .arg(
            Arg::new("signal-port")
            Arg::with_name("signal-port")
                .long("signal-port")
                .value_parser(value_parser!(u16))
                .default_value("8895"),
                .default_value("8895")
                .takes_value(true),
        )
        .arg(Arg::new("rootcanal-port").long("rootcanal-port").value_parser(value_parser!(u16)))
        .arg(Arg::new("btsnoop").long("btsnoop"))
        .arg(Arg::new("btsnooz").long("btsnooz"))
        .arg(Arg::new("btconfig").long("btconfig"))
        .arg(Arg::with_name("rootcanal-port").long("rootcanal-port").takes_value(true))
        .arg(Arg::with_name("btsnoop").long("btsnoop").takes_value(true))
        .arg(Arg::with_name("btsnooz").long("btsnooz").takes_value(true))
        .arg(Arg::with_name("btconfig").long("btconfig").takes_value(true))
        .arg(
            Arg::new("start-stack-now")
            Arg::with_name("start-stack-now")
                .long("start-stack-now")
                .value_parser(value_parser!(bool))
                .default_value("true"),
                .default_value("true")
                .takes_value(true),
        )
        .get_matches();

    let grpc_port = *matches.get_one::<u16>("grpc-port").unwrap();
    let _rootcanal_port = matches.get_one::<u16>("rootcanal-port").cloned();
    let grpc_port = value_t!(matches, "grpc-port", u16).unwrap();
    let _rootcanal_port = value_t!(matches, "rootcanal-port", u16).ok();
    let env = Arc::new(Environment::new(2));

    let btif_intf = Arc::new(Mutex::new(btif::get_btinterface().unwrap()));
@@ -80,7 +75,7 @@ async fn async_main(rt: Arc<Runtime>, mut sigint: mpsc::UnboundedReceiver<()>) {

    let media_service_impl = media_service::MediaServiceImpl::create(rt.clone(), btif_intf.clone());

    let start_stack_now = *matches.get_one::<bool>("start-stack-now").unwrap();
    let start_stack_now = value_t!(matches, "start-stack-now", bool).unwrap();

    if start_stack_now {
        btif_intf.clone().lock().unwrap().enable();
+4 −4
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ mod parser;
#[cfg(test)]
mod test_utils;

#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[derive(Debug)]
enum OutputFormat {
    JSON,
    Rust,
@@ -37,12 +37,12 @@ impl std::str::FromStr for OutputFormat {
#[clap(name = "pdl-parser", about = "Packet Description Language parser tool.")]
struct Opt {
    /// Print tool version and exit.
    #[clap(short, long = "version")]
    #[clap(short, long = "--version")]
    version: bool,

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

    /// Input file.
@@ -51,7 +51,7 @@ struct Opt {
}

fn main() -> Result<(), String> {
    let opt = Opt::parse();
    let opt = Opt::from_args();

    if opt.version {
        println!("Packet Description Language parser version 1.0");