mirror of
https://github.com/gnxlxnxx/cargo-dfu.git
synced 2026-07-27 15:23:02 +02:00
Use clap instead of structopt
- because of the note that they're in maintenance mode: https://github.com/TeXitoi/structopt#maintenance
This commit is contained in:
Generated
+53
-70
@@ -26,15 +26,6 @@ dependencies = [
|
|||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ansi_term"
|
|
||||||
version = "0.11.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
|
|
||||||
dependencies = [
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "atty"
|
name = "atty"
|
||||||
version = "0.2.14"
|
version = "0.2.14"
|
||||||
@@ -78,6 +69,7 @@ name = "cargo-dfu"
|
|||||||
version = "0.0.4"
|
version = "0.0.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cargo-project",
|
"cargo-project",
|
||||||
|
"clap",
|
||||||
"colored",
|
"colored",
|
||||||
"dfu",
|
"dfu",
|
||||||
"goblin",
|
"goblin",
|
||||||
@@ -85,7 +77,6 @@ dependencies = [
|
|||||||
"maplit",
|
"maplit",
|
||||||
"pretty_env_logger",
|
"pretty_env_logger",
|
||||||
"rusb",
|
"rusb",
|
||||||
"structopt",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -130,17 +121,32 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "2.33.3"
|
version = "3.0.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
|
checksum = "7a30c3bf9ff12dfe5dae53f0a96e0febcd18420d1c0e7fad77796d9d5c4b5375"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ansi_term",
|
|
||||||
"atty",
|
"atty",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
|
"clap_derive",
|
||||||
|
"indexmap",
|
||||||
|
"lazy_static",
|
||||||
|
"os_str_bytes",
|
||||||
"strsim",
|
"strsim",
|
||||||
|
"termcolor",
|
||||||
"textwrap",
|
"textwrap",
|
||||||
"unicode-width",
|
]
|
||||||
"vec_map",
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_derive"
|
||||||
|
version = "3.0.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "517358c28fcef6607bf6f76108e02afad7e82297d132a6b846dcc1fc3efcd153"
|
||||||
|
dependencies = [
|
||||||
|
"heck",
|
||||||
|
"proc-macro-error",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -225,13 +231,16 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heck"
|
name = "hashbrown"
|
||||||
version = "0.3.3"
|
version = "0.11.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
|
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
|
||||||
dependencies = [
|
|
||||||
"unicode-segmentation",
|
[[package]]
|
||||||
]
|
name = "heck"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hermit-abi"
|
name = "hermit-abi"
|
||||||
@@ -251,6 +260,16 @@ dependencies = [
|
|||||||
"quick-error",
|
"quick-error",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "indexmap"
|
||||||
|
version = "1.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"hashbrown",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lazy_static"
|
name = "lazy_static"
|
||||||
version = "1.4.0"
|
version = "1.4.0"
|
||||||
@@ -356,6 +375,15 @@ dependencies = [
|
|||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "os_str_bytes"
|
||||||
|
version = "6.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pkg-config"
|
name = "pkg-config"
|
||||||
version = "0.3.22"
|
version = "0.3.22"
|
||||||
@@ -511,33 +539,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strsim"
|
name = "strsim"
|
||||||
version = "0.8.0"
|
version = "0.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "structopt"
|
|
||||||
version = "0.3.25"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "40b9788f4202aa75c240ecc9c15c65185e6a39ccdeb0fd5d008b98825464c87c"
|
|
||||||
dependencies = [
|
|
||||||
"clap",
|
|
||||||
"lazy_static",
|
|
||||||
"structopt-derive",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "structopt-derive"
|
|
||||||
version = "0.4.18"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0"
|
|
||||||
dependencies = [
|
|
||||||
"heck",
|
|
||||||
"proc-macro-error",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
@@ -582,12 +586,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "textwrap"
|
name = "textwrap"
|
||||||
version = "0.11.0"
|
version = "0.14.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
|
checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80"
|
||||||
dependencies = [
|
|
||||||
"unicode-width",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time"
|
name = "time"
|
||||||
@@ -609,18 +610,6 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-segmentation"
|
|
||||||
version = "1.8.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-width"
|
|
||||||
version = "0.1.9"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-xid"
|
name = "unicode-xid"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
@@ -645,12 +634,6 @@ version = "0.2.15"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "vec_map"
|
|
||||||
version = "0.8.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version_check"
|
name = "version_check"
|
||||||
version = "0.9.3"
|
version = "0.9.3"
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ colored = "2.0.0"
|
|||||||
rusb = "0.9.0"
|
rusb = "0.9.0"
|
||||||
pretty_env_logger = "0.3.0"
|
pretty_env_logger = "0.3.0"
|
||||||
cargo-project = "0.2.4"
|
cargo-project = "0.2.4"
|
||||||
structopt = "0.3.2"
|
clap = {version = "3.0.10", features=["derive"]}
|
||||||
maplit = "1.0.2"
|
maplit = "1.0.2"
|
||||||
log = "0.4.6"
|
log = "0.4.6"
|
||||||
dfu = "0.4"
|
dfu = "0.4"
|
||||||
|
|||||||
+18
-17
@@ -4,10 +4,11 @@ use crate::utils::{elf_to_bin, flash_bin, vendor_map};
|
|||||||
use colored::*;
|
use colored::*;
|
||||||
use rusb::{open_device_with_vid_pid, GlobalContext};
|
use rusb::{open_device_with_vid_pid, GlobalContext};
|
||||||
|
|
||||||
|
use clap::Parser;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use structopt::StructOpt;
|
// use structopt::StructOpt;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Initialize the logging backend.
|
// Initialize the logging backend.
|
||||||
@@ -15,7 +16,7 @@ fn main() {
|
|||||||
|
|
||||||
// Get commandline options.
|
// Get commandline options.
|
||||||
// Skip the first arg which is the calling application name.
|
// Skip the first arg which is the calling application name.
|
||||||
let opt = Opt::from_iter(std::env::args().skip(1));
|
let opt = Opt::parse_from(std::env::args());
|
||||||
|
|
||||||
if opt.list_chips {
|
if opt.list_chips {
|
||||||
for vendor in vendor_map() {
|
for vendor in vendor_map() {
|
||||||
@@ -176,36 +177,36 @@ fn parse_hex_16(input: &str) -> Result<u16, std::num::ParseIntError> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[derive(Debug, Parser)]
|
||||||
#[derive(Debug, StructOpt)]
|
#[clap(author, version, about, long_about = None)]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
// `cargo build` arguments
|
// `cargo build` arguments
|
||||||
#[structopt(name = "binary", long = "bin")]
|
#[clap(name = "binary", long = "bin")]
|
||||||
bin: Option<String>,
|
bin: Option<String>,
|
||||||
#[structopt(name = "example", long = "example")]
|
#[clap(name = "example", long = "example")]
|
||||||
example: Option<String>,
|
example: Option<String>,
|
||||||
#[structopt(name = "package", short = "p", long = "package")]
|
#[clap(name = "package", short = 'p', long = "package")]
|
||||||
package: Option<String>,
|
package: Option<String>,
|
||||||
#[structopt(name = "release", long = "release")]
|
#[clap(name = "release", long = "release")]
|
||||||
release: bool,
|
release: bool,
|
||||||
#[structopt(name = "target", long = "target")]
|
#[clap(name = "target", long = "target")]
|
||||||
target: Option<String>,
|
target: Option<String>,
|
||||||
#[structopt(name = "PATH", long = "manifest-path", parse(from_os_str))]
|
#[clap(name = "PATH", long = "manifest-path", parse(from_os_str))]
|
||||||
manifest_path: Option<PathBuf>,
|
manifest_path: Option<PathBuf>,
|
||||||
#[structopt(long)]
|
#[clap(long)]
|
||||||
no_default_features: bool,
|
no_default_features: bool,
|
||||||
#[structopt(long)]
|
#[clap(long)]
|
||||||
all_features: bool,
|
all_features: bool,
|
||||||
#[structopt(long)]
|
#[clap(long)]
|
||||||
features: Vec<String>,
|
features: Vec<String>,
|
||||||
|
|
||||||
#[structopt(name = "pid", long = "pid", parse(try_from_str = parse_hex_16))]
|
#[clap(name = "pid", long = "pid", parse(try_from_str = parse_hex_16))]
|
||||||
pid: Option<u16>,
|
pid: Option<u16>,
|
||||||
#[structopt(name = "vid", long = "vid", parse(try_from_str = parse_hex_16))]
|
#[clap(name = "vid", long = "vid", parse(try_from_str = parse_hex_16))]
|
||||||
vid: Option<u16>,
|
vid: Option<u16>,
|
||||||
|
|
||||||
#[structopt(name = "chip", long = "chip")]
|
#[clap(name = "chip", long = "chip")]
|
||||||
chip: Option<String>,
|
chip: Option<String>,
|
||||||
#[structopt(name = "list-chips", long = "list-chips")]
|
#[clap(name = "list-chips", long = "list-chips")]
|
||||||
list_chips: bool,
|
list_chips: bool,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user