mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
dependency: remove atty
Read input from clap
This commit is contained in:
Generated
-1
@@ -218,7 +218,6 @@ version = "0.8.6"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"ansi_term",
|
"ansi_term",
|
||||||
"assert_cmd",
|
"assert_cmd",
|
||||||
"atty",
|
|
||||||
"clap",
|
"clap",
|
||||||
"clap_complete",
|
"clap_complete",
|
||||||
"clap_mangen",
|
"clap_mangen",
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ strip = true
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
ansi_term = "0.12"
|
ansi_term = "0.12"
|
||||||
atty = "0.2.14"
|
|
||||||
clap = "3.2.17"
|
clap = "3.2.17"
|
||||||
lscolors = "0.13"
|
lscolors = "0.13"
|
||||||
terminal_size = "0.2"
|
terminal_size = "0.2"
|
||||||
|
|||||||
+1
-16
@@ -17,7 +17,6 @@ use filter::AggregateData;
|
|||||||
use progress::PIndicator;
|
use progress::PIndicator;
|
||||||
use progress::ORDERING;
|
use progress::ORDERING;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::io::BufRead;
|
|
||||||
use std::panic;
|
use std::panic;
|
||||||
use std::process;
|
use std::process;
|
||||||
use sysinfo::{System, SystemExt};
|
use sysinfo::{System, SystemExt};
|
||||||
@@ -99,27 +98,13 @@ fn get_regex_value(maybe_value: Option<Values>) -> Vec<Regex> {
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a list of lines from stdin or `None` if there's nothing to read
|
|
||||||
fn get_lines_from_stdin() -> Option<Vec<String>> {
|
|
||||||
atty::isnt(atty::Stream::Stdin).then(|| {
|
|
||||||
std::io::stdin()
|
|
||||||
.lock()
|
|
||||||
.lines()
|
|
||||||
.collect::<Result<_, _>>()
|
|
||||||
.expect("Error reading from stdin")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let options = build_cli().get_matches();
|
let options = build_cli().get_matches();
|
||||||
let config = get_config();
|
let config = get_config();
|
||||||
let stdin_lines = get_lines_from_stdin();
|
|
||||||
|
|
||||||
let target_dirs = match options.values_of("inputs") {
|
let target_dirs = match options.values_of("inputs") {
|
||||||
Some(values) => values.collect(),
|
Some(values) => values.collect(),
|
||||||
None => stdin_lines.as_ref().map_or(vec!["."], |lines| {
|
None => vec!["."],
|
||||||
lines.iter().map(String::as_str).collect()
|
|
||||||
}),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let summarize_file_types = options.is_present("types");
|
let summarize_file_types = options.is_present("types");
|
||||||
|
|||||||
Reference in New Issue
Block a user