summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJedsek <jedsek@qq.com>2022-08-22 23:58:26 +0800
committerandy.boot <bootandy@gmail.com>2022-08-23 09:11:13 +0100
commitf60184ecbbfc0a7ee5794a88f25e071a5e03f541 (patch)
tree8ff31793c008343a244aea7a36d25047950742b2
parent81d52e6e3a6aa5220eb19c72fbc4f9ad75fda7f2 (diff)
Fix the hard code of max depth
-rw-r--r--build.rs3
-rw-r--r--src/cli.rs4
-rw-r--r--src/main.rs2
3 files changed, 5 insertions, 4 deletions
diff --git a/build.rs b/build.rs
index 1755579..443b309 100644
--- a/build.rs
+++ b/build.rs
@@ -6,7 +6,8 @@ include!("src/cli.rs");
fn main() -> Result<(), Error> {
let outdir = "completions";
let app_name = "dust";
- let mut cmd = build_cli();
+ let max_depth = usize::MAX.to_string();
+ let mut cmd = build_cli(&max_depth);
generate_to(Bash, &mut cmd, app_name, outdir)?;
generate_to(Zsh, &mut cmd, app_name, outdir)?;
diff --git a/src/cli.rs b/src/cli.rs
index cc6a07d..2d050df 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -1,6 +1,6 @@
use clap::{Arg, Command};
-pub(crate) fn build_cli() -> Command<'static> {
+pub fn build_cli(max_depth: &str) -> Command {
Command::new("Dust")
.about("Like du but more intuitive")
.version(env!("CARGO_PKG_VERSION"))
@@ -11,7 +11,7 @@ pub(crate) fn build_cli() -> Command<'static> {
.long("depth")
.help("Depth to show")
.takes_value(true)
- .default_value("18446744073709551615")
+ .default_value(max_depth)
)
.arg(
Arg::new("number_of_lines")
diff --git a/src/main.rs b/src/main.rs
index e6a5ec6..7d10b49 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -90,7 +90,7 @@ fn get_regex_value(maybe_value: Option<Values>) -> Vec<Regex> {
}
fn main() {
- let options = build_cli().get_matches();
+ let options = build_cli(&usize::MAX.to_string()).get_matches();
let config = get_config();