From 4b5b990914d4fb4473fadbfdbaf444bc3f56f3b1 Mon Sep 17 00:00:00 2001 From: wcampbell Date: Sat, 2 Nov 2024 19:52:09 -0400 Subject: [PATCH] Replace hand-rolled clap stylings with styles from clap_cargo --- Cargo.lock | 11 +++++++++++ backhand-cli/Cargo.toml | 1 + backhand-cli/src/bin/add.rs | 4 ++-- backhand-cli/src/bin/replace.rs | 4 ++-- backhand-cli/src/bin/unsquashfs.rs | 4 ++-- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f41af92e..e87f0d1d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -135,6 +135,7 @@ version = "0.18.0" dependencies = [ "backhand", "clap", + "clap-cargo", "clap_complete", "color-print", "console", @@ -289,6 +290,16 @@ dependencies = [ "clap_derive", ] +[[package]] +name = "clap-cargo" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b2ea69cefa96b848b73ad516ad1d59a195cdf9263087d977f648a818c8b43e" +dependencies = [ + "anstyle", + "clap", +] + [[package]] name = "clap_builder" version = "4.5.13" diff --git a/backhand-cli/Cargo.toml b/backhand-cli/Cargo.toml index 9442c839..722a76f8 100644 --- a/backhand-cli/Cargo.toml +++ b/backhand-cli/Cargo.toml @@ -23,6 +23,7 @@ rayon = "1.10.0" backhand = { path = "../backhand", default-features = false, version = "0.18.0" } tracing = "0.1.40" color-print = "0.3.6" +clap-cargo = "0.14.1" [lib] bench = false diff --git a/backhand-cli/src/bin/add.rs b/backhand-cli/src/bin/add.rs index 599a9826..9689edf5 100644 --- a/backhand-cli/src/bin/add.rs +++ b/backhand-cli/src/bin/add.rs @@ -5,7 +5,7 @@ use std::path::PathBuf; use std::process::ExitCode; use backhand::{FilesystemReader, FilesystemWriter, NodeHeader}; -use backhand_cli::{after_help, styles}; +use backhand_cli::after_help; use clap::Parser; use tracing::{error, info}; use tracing_subscriber::EnvFilter; @@ -22,7 +22,7 @@ static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; name = "add-backhand", after_help = after_help(false), max_term_width = 98, - styles = styles(), + styles = clap_cargo::style::CLAP_STYLING, )] struct Args { /// Squashfs input image diff --git a/backhand-cli/src/bin/replace.rs b/backhand-cli/src/bin/replace.rs index 702954c5..399149b0 100644 --- a/backhand-cli/src/bin/replace.rs +++ b/backhand-cli/src/bin/replace.rs @@ -4,7 +4,7 @@ use std::path::PathBuf; use std::process::ExitCode; use backhand::{FilesystemReader, FilesystemWriter}; -use backhand_cli::{after_help, styles}; +use backhand_cli::after_help; use clap::Parser; use tracing::error; use tracing_subscriber::EnvFilter; @@ -21,7 +21,7 @@ static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; name = "replace-backhand", after_help = after_help(false), max_term_width = 98, - styles = styles(), + styles = clap_cargo::style::CLAP_STYLING, )] struct Args { /// Squashfs input image diff --git a/backhand-cli/src/bin/unsquashfs.rs b/backhand-cli/src/bin/unsquashfs.rs index abeb6fca..84a6aa5f 100644 --- a/backhand-cli/src/bin/unsquashfs.rs +++ b/backhand-cli/src/bin/unsquashfs.rs @@ -12,7 +12,7 @@ use backhand::{ BufReadSeek, FilesystemReader, InnerNode, Node, NodeHeader, Squashfs, SquashfsBlockDevice, SquashfsCharacterDevice, SquashfsDir, SquashfsFileReader, SquashfsSymlink, DEFAULT_BLOCK_SIZE, }; -use backhand_cli::{after_help, styles}; +use backhand_cli::after_help; use clap::builder::PossibleValuesParser; use clap::{CommandFactory, Parser}; use clap_complete::{generate, Shell}; @@ -84,7 +84,7 @@ pub fn failed(pb: &ProgressBar, s: &str) { name = "unsquashfs-backhand", after_help = after_help(true), max_term_width = 98, - styles = styles(), + styles = clap_cargo::style::CLAP_STYLING, )] struct Args { /// Squashfs file