Skip to content

Commit

Permalink
Use clap instead of structopt (ordinals#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Feb 19, 2022
1 parent 6338abc commit 0c8bd19
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 78 deletions.
125 changes: 67 additions & 58 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ autotests = false
[dependencies]
bitcoin = "0.27.1"
bitcoincore-rpc = "0.14.0"
clap = { version = "3.1.0", features = ["derive"] }
derive_more = "0.99.17"
dirs = "4.0.0"
env_logger = "0.9.0"
Expand All @@ -18,7 +19,6 @@ integer-sqrt = "0.1.5"
jsonrpc = "0.12.1"
log = "0.4.14"
redb = { version = "0.0.4", git = "https://github.com/cberner/redb.git" }
structopt = "0.3.25"

[dev-dependencies]
criterion = "0.3.5"
Expand Down
6 changes: 3 additions & 3 deletions src/arguments.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use super::*;

#[derive(StructOpt)]
#[derive(Parser)]
pub(crate) struct Arguments {
#[structopt(flatten)]
#[clap(flatten)]
options: Options,
#[structopt(subcommand)]
#[clap(subcommand)]
subcommand: Subcommand,
}

Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use {
options::Options, ordinal::Ordinal, sat_point::SatPoint, subcommand::Subcommand,
},
bitcoin::{blockdata::constants::COIN_VALUE, consensus::Encodable, Block, OutPoint, Transaction},
clap::Parser,
derive_more::{Display, FromStr},
integer_cbrt::IntegerCubeRoot,
integer_sqrt::IntegerSquareRoot,
Expand All @@ -20,7 +21,6 @@ use {
str::FromStr,
time::{Duration, Instant},
},
structopt::StructOpt,
};

mod arguments;
Expand All @@ -33,13 +33,13 @@ mod ordinal;
mod sat_point;
mod subcommand;

type Error = Box<dyn std::error::Error>;
type Error = Box<dyn std::error::Error + Send + Sync>;
type Result<T = (), E = Error> = std::result::Result<T, E>;

fn main() {
env_logger::init();

if let Err(error) = Arguments::from_args().run() {
if let Err(error) = Arguments::parse().run() {
eprintln!("error: {}", error);
process::exit(1);
}
Expand Down
8 changes: 4 additions & 4 deletions src/options.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use super::*;

#[derive(StructOpt)]
#[derive(Parser)]
pub(crate) struct Options {
#[structopt(long, default_value = "1MiB")]
#[clap(long, default_value = "1MiB")]
pub(crate) index_size: Bytes,
#[structopt(long)]
#[clap(long)]
pub(crate) cookie_file: Option<PathBuf>,
#[structopt(long)]
#[clap(long)]
pub(crate) rpc_url: Option<String>,
}
2 changes: 1 addition & 1 deletion src/subcommand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mod range;
mod supply;
mod traits;

#[derive(StructOpt)]
#[derive(Parser)]
pub(crate) enum Subcommand {
Epochs,
Find(find::Find),
Expand Down
6 changes: 3 additions & 3 deletions src/subcommand/find.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use super::*;

#[derive(StructOpt)]
#[derive(Parser)]
pub(crate) struct Find {
#[structopt(long)]
#[clap(long)]
as_of_height: u64,
#[structopt(long)]
#[clap(long)]
slot: bool,
ordinal: Ordinal,
}
Expand Down
2 changes: 1 addition & 1 deletion src/subcommand/list.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;

#[derive(StructOpt)]
#[derive(Parser)]
pub(crate) struct List {
outpoint: OutPoint,
}
Expand Down
2 changes: 1 addition & 1 deletion src/subcommand/name.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;

#[derive(StructOpt)]
#[derive(Parser)]
pub(crate) struct Name {
name: String,
}
Expand Down
4 changes: 2 additions & 2 deletions src/subcommand/range.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::*;

#[derive(StructOpt)]
#[derive(Parser)]
pub(crate) struct Range {
#[structopt(long)]
#[clap(long)]
name: bool,
height: Height,
}
Expand Down
2 changes: 1 addition & 1 deletion src/subcommand/traits.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;

#[derive(StructOpt)]
#[derive(Parser)]
pub(crate) struct Traits {
ordinal: Ordinal,
}
Expand Down

0 comments on commit 0c8bd19

Please sign in to comment.