Skip to content

Commit

Permalink
Use clap's dynamic String feature rather than another dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilfred committed Jan 4, 2025
1 parent 2c1feae commit 44be153
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 34 deletions.
27 changes: 0 additions & 27 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pkg-fmt = "zip"

[dependencies]
regex = "1.10.4"
clap = { version = "4.0.0", features = ["cargo", "env", "wrap_help"] }
clap = { version = "4.0.0", features = ["cargo", "env", "wrap_help", "string"] }
itertools = "0.11.0"
typed-arena = "2.0.2"
rustc-hash = "2.0.0"
Expand All @@ -55,7 +55,6 @@ radix-heap = "0.4.2"
# a slightly more aggressive MSRV than difftastic. Constrain ignore to
# a known-good max version.
ignore = ">= 0.4, < 0.4.24"
const_format = "0.2.22"
owo-colors = "3.5.0"
wu-diff = "0.1.2"
rayon = "1.7.0"
Expand Down
9 changes: 4 additions & 5 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::{
};

use clap::{crate_authors, crate_description, value_parser, Arg, ArgAction, Command};
use const_format::formatcp;
use crossterm::tty::IsTty;
use itertools::Itertools;

Expand Down Expand Up @@ -169,7 +168,7 @@ fn app() -> clap::Command {
.action(ArgAction::Set)
.long_help("Treat a tab as this many spaces.")
.env("DFT_TAB_WIDTH")
.default_value(formatcp!("{}", DEFAULT_TAB_WIDTH))
.default_value(format!("{}", DEFAULT_TAB_WIDTH))
.value_parser(clap::value_parser!(usize))
.required(false),
)
Expand Down Expand Up @@ -287,7 +286,7 @@ When multiple overrides are specified, the first matching override wins."))
.value_name("LIMIT")
.action(ArgAction::Set)
.help("Use a text diff if either input file exceeds this size.")
.default_value(formatcp!("{}", DEFAULT_BYTE_LIMIT))
.default_value(format!("{}", DEFAULT_BYTE_LIMIT))
.env("DFT_BYTE_LIMIT")
.value_parser(clap::value_parser!(usize))
.required(false),
Expand All @@ -296,7 +295,7 @@ When multiple overrides are specified, the first matching override wins."))
Arg::new("graph-limit").long("graph-limit")
.value_name("LIMIT")
.help("Use a text diff if the structural graph exceed this number of nodes in memory.")
.default_value(formatcp!("{}", DEFAULT_GRAPH_LIMIT))
.default_value(format!("{}", DEFAULT_GRAPH_LIMIT))
.action(ArgAction::Set)
.env("DFT_GRAPH_LIMIT")
.value_parser(clap::value_parser!(usize))
Expand All @@ -307,7 +306,7 @@ When multiple overrides are specified, the first matching override wins."))
.value_name("LIMIT")
.action(ArgAction::Set)
.help("Use a text diff if the number of parse errors exceeds this value.")
.default_value(formatcp!("{}", DEFAULT_PARSE_ERROR_LIMIT))
.default_value(format!("{}", DEFAULT_PARSE_ERROR_LIMIT))
.env("DFT_PARSE_ERROR_LIMIT")
.value_parser(clap::value_parser!(usize))
.required(false),
Expand Down

0 comments on commit 44be153

Please sign in to comment.