You've already forked uutils.github.io
mirror of
https://github.com/uutils/uutils.github.io.git
synced 2026-06-10 16:12:28 -07:00
deploy: f0e8d44e6e
This commit is contained in:
+1
-1
File diff suppressed because one or more lines are too long
@@ -1994,6 +1994,7 @@
|
||||
<a href="#1994" id="1994">1994</a>
|
||||
<a href="#1995" id="1995">1995</a>
|
||||
<a href="#1996" id="1996">1996</a>
|
||||
<a href="#1997" id="1997">1997</a>
|
||||
</pre></div><pre class="rust"><code><span class="attr">#![allow(clippy::missing_safety_doc)]
|
||||
#![allow(clippy::extra_unused_lifetimes)]
|
||||
|
||||
@@ -2379,6 +2380,7 @@
|
||||
backup_control::BACKUP_CONTROL_LONG_HELP
|
||||
))
|
||||
.infer_long_args(<span class="bool-val">true</span>)
|
||||
.args_override_self(<span class="bool-val">true</span>)
|
||||
.arg(
|
||||
Arg::new(options::TARGET_DIRECTORY)
|
||||
.short(<span class="string">'t'</span>)
|
||||
|
||||
@@ -678,11 +678,6 @@
|
||||
<a href="#678" id="678">678</a>
|
||||
<a href="#679" id="679">679</a>
|
||||
<a href="#680" id="680">680</a>
|
||||
<a href="#681" id="681">681</a>
|
||||
<a href="#682" id="682">682</a>
|
||||
<a href="#683" id="683">683</a>
|
||||
<a href="#684" id="684">684</a>
|
||||
<a href="#685" id="685">685</a>
|
||||
</pre></div><pre class="rust"><code><span class="comment">// * This file is part of the uutils coreutils package.
|
||||
// *
|
||||
// * For the full copyright and license information, please view the LICENSE
|
||||
@@ -692,12 +687,11 @@
|
||||
|
||||
</span><span class="kw">use </span><span class="kw">crate</span>::paths::Input;
|
||||
<span class="kw">use crate</span>::{parse, platform, Quotable};
|
||||
<span class="kw">use </span>clap::crate_version;
|
||||
<span class="kw">use </span>clap::{crate_version, value_parser};
|
||||
<span class="kw">use </span>clap::{Arg, ArgAction, ArgMatches, Command};
|
||||
<span class="kw">use </span>fundu::{DurationParser, SaturatingInto};
|
||||
<span class="kw">use </span>is_terminal::IsTerminal;
|
||||
<span class="kw">use </span>same_file::Handle;
|
||||
<span class="kw">use </span>std::collections::VecDeque;
|
||||
<span class="kw">use </span>std::ffi::OsString;
|
||||
<span class="kw">use </span>std::time::Duration;
|
||||
<span class="kw">use </span>uucore::error::{UResult, USimpleError, UUsageError};
|
||||
@@ -826,7 +820,8 @@
|
||||
<span class="kw">pub </span>use_polling: bool,
|
||||
<span class="kw">pub </span>verbose: bool,
|
||||
<span class="kw">pub </span>presume_input_pipe: bool,
|
||||
<span class="kw">pub </span>inputs: VecDeque<Input>,
|
||||
<span class="doccomment">/// `FILE(s)` positional arguments
|
||||
</span><span class="kw">pub </span>inputs: Vec<Input>,
|
||||
}
|
||||
|
||||
<span class="kw">impl </span>Default <span class="kw">for </span>Settings {
|
||||
@@ -858,11 +853,11 @@
|
||||
}
|
||||
settings.mode = FilterMode::from_obsolete_args(args);
|
||||
<span class="kw">let </span>input = <span class="kw">if let </span><span class="prelude-val">Some</span>(name) = name {
|
||||
Input::from(<span class="kw-2">&</span>name)
|
||||
Input::from(name)
|
||||
} <span class="kw">else </span>{
|
||||
Input::default()
|
||||
};
|
||||
settings.inputs.push_back(input);
|
||||
settings.inputs.push(input);
|
||||
settings
|
||||
}
|
||||
|
||||
@@ -970,19 +965,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>inputs: VecDeque<Input> = matches
|
||||
.get_many::<String>(options::ARG_FILES)
|
||||
.map(|v| v.map(|string| Input::from(<span class="kw-2">&</span>string)).collect())
|
||||
.unwrap_or_default();
|
||||
settings.inputs = matches
|
||||
.get_many::<OsString>(options::ARG_FILES)
|
||||
.map(|v| v.map(Input::from).collect())
|
||||
.unwrap_or_else(|| <span class="macro">vec!</span>[Input::default()]);
|
||||
|
||||
<span class="comment">// apply default and add '-' to inputs if none is present
|
||||
</span><span class="kw">if </span>inputs.is_empty() {
|
||||
inputs.push_front(Input::default());
|
||||
}
|
||||
|
||||
settings.verbose = inputs.len() > <span class="number">1 </span>&& !matches.get_flag(options::verbosity::QUIET);
|
||||
|
||||
settings.inputs = inputs;
|
||||
settings.verbose =
|
||||
settings.inputs.len() > <span class="number">1 </span>&& !matches.get_flag(options::verbosity::QUIET);
|
||||
|
||||
<span class="prelude-val">Ok</span>(settings)
|
||||
}
|
||||
@@ -1278,6 +1267,7 @@
|
||||
Arg::new(options::ARG_FILES)
|
||||
.action(ArgAction::Append)
|
||||
.num_args(<span class="number">1</span>..)
|
||||
.value_parser(<span class="macro">value_parser!</span>(OsString))
|
||||
.value_hint(clap::ValueHint::FilePath),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -602,7 +602,6 @@
|
||||
<a href="#602" id="602">602</a>
|
||||
<a href="#603" id="603">603</a>
|
||||
<a href="#604" id="604">604</a>
|
||||
<a href="#605" id="605">605</a>
|
||||
</pre></div><pre class="rust"><code><span class="comment">// * This file is part of the uutils coreutils package.
|
||||
// *
|
||||
// * For the full copyright and license information, please view the LICENSE
|
||||
@@ -615,7 +614,6 @@
|
||||
<span class="kw">use </span><span class="kw">crate</span>::paths::{Input, InputKind, MetadataExtTail, PathExtTail};
|
||||
<span class="kw">use crate</span>::{platform, text};
|
||||
<span class="kw">use </span>notify::{RecommendedWatcher, RecursiveMode, Watcher, WatcherKind};
|
||||
<span class="kw">use </span>std::collections::VecDeque;
|
||||
<span class="kw">use </span>std::io::BufRead;
|
||||
<span class="kw">use </span>std::path::{Path, PathBuf};
|
||||
<span class="kw">use </span>std::sync::mpsc::{<span class="self">self</span>, channel, Receiver};
|
||||
@@ -875,7 +873,7 @@
|
||||
<span class="self">self</span>.follow_name() && <span class="self">self</span>.retry
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>init_files(<span class="kw-2">&mut </span><span class="self">self</span>, inputs: <span class="kw-2">&</span>VecDeque<Input>) -> UResult<()> {
|
||||
<span class="kw">fn </span>init_files(<span class="kw-2">&mut </span><span class="self">self</span>, inputs: <span class="kw-2">&</span>Vec<Input>) -> UResult<()> {
|
||||
<span class="kw">if let </span><span class="prelude-val">Some</span>(watcher_rx) = <span class="kw-2">&mut </span><span class="self">self</span>.watcher_rx {
|
||||
<span class="kw">for </span>input <span class="kw">in </span>inputs {
|
||||
<span class="kw">match </span>input.kind() {
|
||||
|
||||
@@ -235,6 +235,19 @@
|
||||
<a href="#235" id="235">235</a>
|
||||
<a href="#236" id="236">236</a>
|
||||
<a href="#237" id="237">237</a>
|
||||
<a href="#238" id="238">238</a>
|
||||
<a href="#239" id="239">239</a>
|
||||
<a href="#240" id="240">240</a>
|
||||
<a href="#241" id="241">241</a>
|
||||
<a href="#242" id="242">242</a>
|
||||
<a href="#243" id="243">243</a>
|
||||
<a href="#244" id="244">244</a>
|
||||
<a href="#245" id="245">245</a>
|
||||
<a href="#246" id="246">246</a>
|
||||
<a href="#247" id="247">247</a>
|
||||
<a href="#248" id="248">248</a>
|
||||
<a href="#249" id="249">249</a>
|
||||
<a href="#250" id="250">250</a>
|
||||
</pre></div><pre class="rust"><code><span class="comment">// * This file is part of the uutils coreutils package.
|
||||
// *
|
||||
// * For the full copyright and license information, please view the LICENSE
|
||||
@@ -257,6 +270,28 @@
|
||||
Stdin,
|
||||
}
|
||||
|
||||
<span class="attr">#[cfg(unix)]
|
||||
</span><span class="kw">impl </span>From<<span class="kw-2">&</span>OsStr> <span class="kw">for </span>InputKind {
|
||||
<span class="kw">fn </span>from(value: <span class="kw-2">&</span>OsStr) -> <span class="self">Self </span>{
|
||||
<span class="kw">if </span>value == OsStr::new(<span class="string">"-"</span>) {
|
||||
<span class="self">Self</span>::Stdin
|
||||
} <span class="kw">else </span>{
|
||||
<span class="self">Self</span>::File(PathBuf::from(value))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="attr">#[cfg(not(unix))]
|
||||
</span><span class="kw">impl </span>From<<span class="kw-2">&</span>OsStr> <span class="kw">for </span>InputKind {
|
||||
<span class="kw">fn </span>from(value: <span class="kw-2">&</span>OsStr) -> <span class="self">Self </span>{
|
||||
<span class="kw">if </span>value == OsStr::new(text::DASH) {
|
||||
<span class="self">Self</span>::Stdin
|
||||
} <span class="kw">else </span>{
|
||||
<span class="self">Self</span>::File(PathBuf::from(value))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<span class="attr">#[derive(Debug, Clone)]
|
||||
</span><span class="kw">pub struct </span>Input {
|
||||
kind: InputKind,
|
||||
@@ -264,22 +299,13 @@
|
||||
}
|
||||
|
||||
<span class="kw">impl </span>Input {
|
||||
<span class="kw">pub fn </span>from<T: AsRef<OsStr>>(string: <span class="kw-2">&</span>T) -> <span class="self">Self </span>{
|
||||
<span class="kw">let </span>kind = <span class="kw">if </span>string.as_ref() == Path::new(text::DASH) {
|
||||
InputKind::Stdin
|
||||
} <span class="kw">else </span>{
|
||||
InputKind::File(PathBuf::from(string.as_ref()))
|
||||
};
|
||||
<span class="kw">pub fn </span>from<T: AsRef<OsStr>>(string: T) -> <span class="self">Self </span>{
|
||||
<span class="kw">let </span>string = string.as_ref();
|
||||
|
||||
<span class="kw">let </span>kind = string.into();
|
||||
<span class="kw">let </span>display_name = <span class="kw">match </span>kind {
|
||||
InputKind::File(<span class="kw">_</span>) => string.as_ref().to_string_lossy().to_string(),
|
||||
InputKind::Stdin => {
|
||||
<span class="kw">if </span><span class="macro">cfg!</span>(unix) {
|
||||
text::STDIN_HEADER.to_string()
|
||||
} <span class="kw">else </span>{
|
||||
string.as_ref().to_string_lossy().to_string()
|
||||
}
|
||||
}
|
||||
InputKind::File(<span class="kw">_</span>) => string.to_string_lossy().to_string(),
|
||||
InputKind::Stdin => text::STDIN_HEADER.to_string(),
|
||||
};
|
||||
|
||||
<span class="self">Self </span>{ kind, display_name }
|
||||
|
||||
@@ -693,13 +693,9 @@
|
||||
) {
|
||||
(<span class="prelude-val">Some</span>(reference), <span class="prelude-val">Some</span>(date)) => {
|
||||
<span class="kw">let </span>(atime, mtime) = stat(Path::new(reference), !matches.get_flag(options::NO_DEREF))<span class="question-mark">?</span>;
|
||||
<span class="kw">if let </span><span class="prelude-val">Ok</span>(offset) = humantime_to_duration::from_str(date) {
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>seconds = offset.whole_seconds();
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>nanos = offset.subsec_nanoseconds();
|
||||
<span class="kw">if </span>nanos < <span class="number">0 </span>{
|
||||
nanos += <span class="number">1_000_000_000</span>;
|
||||
seconds -= <span class="number">1</span>;
|
||||
}
|
||||
<span class="kw">if let </span><span class="prelude-val">Ok</span>(offset) = parse_datetime::from_str(date) {
|
||||
<span class="kw">let </span>seconds = offset.num_seconds();
|
||||
<span class="kw">let </span>nanos = offset.num_nanoseconds().unwrap_or(<span class="number">0</span>) % <span class="number">1_000_000_000</span>;
|
||||
|
||||
<span class="kw">let </span>ref_atime_secs = atime.unix_seconds();
|
||||
<span class="kw">let </span>ref_atime_nanos = atime.nanoseconds();
|
||||
@@ -1054,9 +1050,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">if let </span><span class="prelude-val">Ok</span>(duration) = humantime_to_duration::from_str(s) {
|
||||
<span class="kw">if let </span><span class="prelude-val">Ok</span>(duration) = parse_datetime::from_str(s) {
|
||||
<span class="kw">let </span>now_local = time::OffsetDateTime::now_local().unwrap();
|
||||
<span class="kw">let </span>diff = now_local.checked_add(duration).unwrap();
|
||||
<span class="kw">let </span>diff = now_local
|
||||
.checked_add(time::Duration::nanoseconds(
|
||||
duration.num_nanoseconds().unwrap(),
|
||||
))
|
||||
.unwrap();
|
||||
<span class="kw">return </span><span class="prelude-val">Ok</span>(local_dt_to_filetime(diff));
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user