Skip to content
This repository has been archived by the owner on Apr 14, 2024. It is now read-only.

Commit

Permalink
Merge pull request #52 from chenxiaolong/clap
Browse files Browse the repository at this point in the history
Switch from structopt to clap
  • Loading branch information
chenxiaolong authored Sep 16, 2022
2 parents eaa2338 + 1bf174e commit 924afd6
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 82 deletions.
133 changes: 58 additions & 75 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ log = "0.4.17"
retry = "1.3.1"
rexpect = "0.4.0"
serde_json = "1.0.85"
# We cannot switch to clap v3 because its MSRV is too high for the distros that
# we provide binary packages for: https://github.com/clap-rs/clap/issues/3267
structopt = "0.3.26"
thiserror = "1.0.35"
tokio-stream = "0.1.9"
toml = "0.5.9"

[dependencies.clap]
version = "3.2.22"
features = ["derive"]

[dependencies.serde]
version = "1.0.144"
features = ["derive"]
Expand Down
8 changes: 4 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ use {
},
u8,
},
clap::Parser,
futures::stream::FuturesUnordered,
log::{debug, error, info, trace},
retry::retry_with_index,
structopt::StructOpt,
tokio::{
task,
time::sleep,
Expand Down Expand Up @@ -347,15 +347,15 @@ fn bool_env(name: &str, default: bool) -> bool {
}
}

#[derive(StructOpt, Debug)]
#[derive(Debug, Parser)]
struct Opt {
/// Path to config file
#[structopt(short, long)]
#[clap(short, long)]
config: PathBuf,
}

async fn main_wrapper() -> Result<()> {
let opt = Opt::from_args();
let opt = Opt::parse();
let config = load_config(&opt.config)?;

let pkg_name = env!("CARGO_PKG_NAME").replace('-', "_");
Expand Down

0 comments on commit 924afd6

Please sign in to comment.