mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
Feature: Config file
Read flags for several params from config file. This was a popular requested feature (many people want to run with -r on by default).
This commit is contained in:
+14
-12
@@ -9,6 +9,7 @@ use std::process;
|
||||
use self::display::draw_it;
|
||||
use clap::{crate_version, Arg};
|
||||
use clap::{Command, Values};
|
||||
use config::get_config;
|
||||
use dir_walker::{walk_it, WalkData};
|
||||
use filter::get_biggest;
|
||||
use filter_type::get_all_file_types;
|
||||
@@ -19,6 +20,7 @@ use terminal_size::{terminal_size, Height, Width};
|
||||
use utils::get_filesystem_devices;
|
||||
use utils::simplify_dir_names;
|
||||
|
||||
mod config;
|
||||
mod dir_walker;
|
||||
mod display;
|
||||
mod display_node;
|
||||
@@ -209,15 +211,17 @@ fn main() {
|
||||
.number_of_values(1)
|
||||
.help("Specify width of output overriding the auto detection of terminal width"),
|
||||
)
|
||||
.arg(Arg::new("inputs").multiple_occurrences(true).default_value("."))
|
||||
.arg(
|
||||
Arg::new("iso")
|
||||
.short('H')
|
||||
.long("si")
|
||||
.help("print sizes in powers of 1000 (e.g., 1.1G)")
|
||||
)
|
||||
.arg(Arg::new("inputs").multiple_occurrences(true).default_value("."))
|
||||
.get_matches();
|
||||
|
||||
let config = get_config();
|
||||
|
||||
let target_dirs = options
|
||||
.values_of("inputs")
|
||||
.expect("Should be a default value here")
|
||||
@@ -254,15 +258,14 @@ fn main() {
|
||||
})
|
||||
.unwrap_or(default_height);
|
||||
|
||||
let no_colors = init_color(options.is_present("no_colors"));
|
||||
let use_apparent_size = options.is_present("display_apparent_size");
|
||||
let no_colors = init_color(config.get_no_colors(&options));
|
||||
|
||||
let ignore_directories = options
|
||||
.values_of("ignore_directory")
|
||||
.unwrap_or_default()
|
||||
.map(PathBuf::from);
|
||||
|
||||
let by_filecount = options.is_present("by_filecount");
|
||||
let ignore_hidden = options.is_present("ignore_hidden");
|
||||
let limit_filesystem = options.is_present("limit_filesystem");
|
||||
|
||||
let simplified_dirs = simplify_dir_names(target_dirs);
|
||||
@@ -279,9 +282,9 @@ fn main() {
|
||||
filter_regex: &filter_regexs,
|
||||
invert_filter_regex: &invert_filter_regexs,
|
||||
allowed_filesystems,
|
||||
use_apparent_size,
|
||||
use_apparent_size: config.get_apparent_size(&options),
|
||||
by_filecount,
|
||||
ignore_hidden,
|
||||
ignore_hidden: config.get_ignore_hidden(&options),
|
||||
};
|
||||
// Larger stack size to handle cases with lots of nested directories
|
||||
rayon::ThreadPoolBuilder::new()
|
||||
@@ -304,18 +307,17 @@ fn main() {
|
||||
if has_errors {
|
||||
eprintln!("Did not have permissions for all directories");
|
||||
}
|
||||
|
||||
if let Some(root_node) = tree {
|
||||
draw_it(
|
||||
options.is_present("display_full_paths"),
|
||||
!options.is_present("reverse"),
|
||||
config.get_full_paths(&options),
|
||||
!config.get_reverse(&options),
|
||||
no_colors,
|
||||
options.is_present("no_bars"),
|
||||
config.get_no_bars(&options),
|
||||
terminal_width,
|
||||
by_filecount,
|
||||
&root_node,
|
||||
options.is_present("iso"),
|
||||
options.is_present("skip_total"),
|
||||
config.get_iso(&options),
|
||||
config.get_skip_total(&options),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user