mirror of
https://github.com/chirpstack/chirpstack.git
synced 2025-06-18 15:28:12 +00:00
Update clap to v4.
This commit is contained in:
43
Cargo.lock
generated
43
Cargo.lock
generated
@ -731,7 +731,7 @@ dependencies = [
|
|||||||
"bitflags",
|
"bitflags",
|
||||||
"cexpr",
|
"cexpr",
|
||||||
"clang-sys",
|
"clang-sys",
|
||||||
"clap",
|
"clap 3.2.22",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"lazycell",
|
"lazycell",
|
||||||
@ -904,7 +904,7 @@ dependencies = [
|
|||||||
"bytes",
|
"bytes",
|
||||||
"chirpstack_api",
|
"chirpstack_api",
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap 4.0.8",
|
||||||
"diesel",
|
"diesel",
|
||||||
"diesel_migrations",
|
"diesel_migrations",
|
||||||
"futures",
|
"futures",
|
||||||
@ -1028,13 +1028,41 @@ checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"atty",
|
"atty",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"clap_lex",
|
"clap_lex 0.2.4",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"strsim",
|
"strsim",
|
||||||
"termcolor",
|
"termcolor",
|
||||||
"textwrap",
|
"textwrap",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap"
|
||||||
|
version = "4.0.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5840cd9093aabeabf7fd932754c435b7674520fc3ddc935c397837050f0f1e4b"
|
||||||
|
dependencies = [
|
||||||
|
"atty",
|
||||||
|
"bitflags",
|
||||||
|
"clap_derive",
|
||||||
|
"clap_lex 0.3.0",
|
||||||
|
"once_cell",
|
||||||
|
"strsim",
|
||||||
|
"termcolor",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_derive"
|
||||||
|
version = "4.0.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "92289ffc6fb4a85d85c246ddb874c05a87a2e540fb6ad52f7ca07c8c1e1840b1"
|
||||||
|
dependencies = [
|
||||||
|
"heck",
|
||||||
|
"proc-macro-error",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_lex"
|
name = "clap_lex"
|
||||||
version = "0.2.4"
|
version = "0.2.4"
|
||||||
@ -1044,6 +1072,15 @@ dependencies = [
|
|||||||
"os_str_bytes",
|
"os_str_bytes",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_lex"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8"
|
||||||
|
dependencies = [
|
||||||
|
"os_str_bytes",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cmac"
|
name = "cmac"
|
||||||
version = "0.7.1"
|
version = "0.7.1"
|
||||||
|
@ -11,7 +11,7 @@ license = "MIT"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# CLI interface
|
# CLI interface
|
||||||
clap = "3.2"
|
clap = { version = "4.0", features = ["derive"] }
|
||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
serde = { version = "1.0", features = ["derive", "rc"] }
|
serde = { version = "1.0", features = ["derive", "rc"] }
|
||||||
|
@ -12,7 +12,7 @@ use std::process;
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use clap::{App, Arg};
|
use clap::{Parser, Subcommand};
|
||||||
use tracing::Level;
|
use tracing::Level;
|
||||||
use tracing_subscriber::{filter, prelude::*};
|
use tracing_subscriber::{filter, prelude::*};
|
||||||
|
|
||||||
@ -41,57 +41,41 @@ mod storage;
|
|||||||
mod test;
|
mod test;
|
||||||
mod uplink;
|
mod uplink;
|
||||||
|
|
||||||
|
#[derive(Parser)]
|
||||||
|
#[command(author, version, about, long_about = None)]
|
||||||
|
struct Cli {
|
||||||
|
/// Path to configuration directory
|
||||||
|
#[arg(short, long, value_name = "DIR")]
|
||||||
|
config: String,
|
||||||
|
|
||||||
|
#[command(subcommand)]
|
||||||
|
command: Option<Commands>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Subcommand)]
|
||||||
|
enum Commands {
|
||||||
|
/// Print the configuration template
|
||||||
|
Configfile {},
|
||||||
|
|
||||||
|
/// Print the device-session for debugging
|
||||||
|
PrintDs {
|
||||||
|
/// Device EUI
|
||||||
|
#[arg(long, value_name = "DEV_EUI")]
|
||||||
|
dev_eui: String,
|
||||||
|
},
|
||||||
|
|
||||||
|
/// Import TheThingsNetwork LoRaWAN devices repository
|
||||||
|
ImportTtnLorawanDevices {
|
||||||
|
/// Path to repository root.
|
||||||
|
#[arg(short, long, value_name = "DIR")]
|
||||||
|
dir: String,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
// read CLI
|
let cli = Cli::parse();
|
||||||
let matches = App::new("chirpstack")
|
config::load(Path::new(&cli.config))?;
|
||||||
.version(env!("CARGO_PKG_VERSION"))
|
|
||||||
.author("Orne Brocaar <info@brocaar.com>")
|
|
||||||
.about("ChirpStack open-source LoRaWAN network-server")
|
|
||||||
.arg(
|
|
||||||
Arg::with_name("config-dir")
|
|
||||||
.required(true)
|
|
||||||
.short('c')
|
|
||||||
.long("config-dir")
|
|
||||||
.value_name("DIR")
|
|
||||||
.multiple(false)
|
|
||||||
.number_of_values(1)
|
|
||||||
.help("Path to configuration directory")
|
|
||||||
.takes_value(true),
|
|
||||||
)
|
|
||||||
.subcommand(App::new("configfile").about("Print the configuration template"))
|
|
||||||
.subcommand(
|
|
||||||
App::new("print-ds")
|
|
||||||
.about("Print the device-session for debugging")
|
|
||||||
.arg(
|
|
||||||
Arg::with_name("dev-eui")
|
|
||||||
.required(true)
|
|
||||||
.long("dev-eui")
|
|
||||||
.value_name("DEV_EUI")
|
|
||||||
.multiple(false)
|
|
||||||
.help("Device EUI")
|
|
||||||
.takes_value(true),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.subcommand(
|
|
||||||
App::new("import-ttn-lorawan-devices")
|
|
||||||
.about("Import TheThingsNetwork LoRaWAN devices repository")
|
|
||||||
.arg(
|
|
||||||
Arg::with_name("dir")
|
|
||||||
.required(true)
|
|
||||||
.short('d')
|
|
||||||
.long("dir")
|
|
||||||
.value_name("DIR")
|
|
||||||
.multiple(false)
|
|
||||||
.number_of_values(1)
|
|
||||||
.help("Path to repository root")
|
|
||||||
.takes_value(true),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.get_matches();
|
|
||||||
|
|
||||||
let config_dir = matches.get_one::<String>("config-dir").unwrap();
|
|
||||||
config::load(Path::new(&config_dir))?;
|
|
||||||
|
|
||||||
let conf = config::get();
|
let conf = config::get();
|
||||||
let filter = filter::Targets::new().with_targets(vec![
|
let filter = filter::Targets::new().with_targets(vec![
|
||||||
@ -105,22 +89,19 @@ async fn main() -> Result<()> {
|
|||||||
.with(filter)
|
.with(filter)
|
||||||
.init();
|
.init();
|
||||||
|
|
||||||
if matches.subcommand_matches("configfile").is_some() {
|
if let Some(Commands::Configfile {}) = &cli.command {
|
||||||
cmd::configfile::run();
|
cmd::configfile::run();
|
||||||
process::exit(0);
|
process::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(v) = matches.subcommand_matches("print-ds") {
|
if let Some(Commands::PrintDs { dev_eui }) = &cli.command {
|
||||||
let dev_eui = v.get_one::<String>("dev-eui").unwrap();
|
|
||||||
let dev_eui = EUI64::from_str(dev_eui).unwrap();
|
let dev_eui = EUI64::from_str(dev_eui).unwrap();
|
||||||
|
|
||||||
cmd::print_ds::run(&dev_eui).await.unwrap();
|
cmd::print_ds::run(&dev_eui).await.unwrap();
|
||||||
process::exit(0);
|
process::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(v) = matches.subcommand_matches("import-ttn-lorawan-devices") {
|
if let Some(Commands::ImportTtnLorawanDevices { dir }) = &cli.command {
|
||||||
let dir = v.get_one::<String>("dir").unwrap();
|
cmd::import_ttn_lorawan_devices::run(Path::new(&dir))
|
||||||
cmd::import_ttn_lorawan_devices::run(Path::new(dir))
|
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
process::exit(0);
|
process::exit(0);
|
||||||
|
Reference in New Issue
Block a user